pub trait Io {
Show 19 methods
// Required methods
fn addr(&self) -> usize;
fn maxsize(&self) -> usize;
// Provided methods
fn io_addr<U>(&self, offset: usize) -> Result<usize> { ... }
fn try_read8(&self, _offset: usize) -> Result<u8>
where Self: IoCapable<u8> { ... }
fn try_read16(&self, _offset: usize) -> Result<u16>
where Self: IoCapable<u16> { ... }
fn try_read32(&self, _offset: usize) -> Result<u32>
where Self: IoCapable<u32> { ... }
fn try_read64(&self, _offset: usize) -> Result<u64>
where Self: IoCapable<u64> { ... }
fn try_write8(&self, _value: u8, _offset: usize) -> Result
where Self: IoCapable<u8> { ... }
fn try_write16(&self, _value: u16, _offset: usize) -> Result
where Self: IoCapable<u16> { ... }
fn try_write32(&self, _value: u32, _offset: usize) -> Result
where Self: IoCapable<u32> { ... }
fn try_write64(&self, _value: u64, _offset: usize) -> Result
where Self: IoCapable<u64> { ... }
fn read8(&self, _offset: usize) -> u8
where Self: IoKnownSize + IoCapable<u8> { ... }
fn read16(&self, _offset: usize) -> u16
where Self: IoKnownSize + IoCapable<u16> { ... }
fn read32(&self, _offset: usize) -> u32
where Self: IoKnownSize + IoCapable<u32> { ... }
fn read64(&self, _offset: usize) -> u64
where Self: IoKnownSize + IoCapable<u64> { ... }
fn write8(&self, _value: u8, _offset: usize)
where Self: IoKnownSize + IoCapable<u8> { ... }
fn write16(&self, _value: u16, _offset: usize)
where Self: IoKnownSize + IoCapable<u16> { ... }
fn write32(&self, _value: u32, _offset: usize)
where Self: IoKnownSize + IoCapable<u32> { ... }
fn write64(&self, _value: u64, _offset: usize)
where Self: IoKnownSize + IoCapable<u64> { ... }
}Expand description
Types implementing this trait (e.g. MMIO BARs or PCI config regions) can perform I/O operations on regions of memory.
This is an abstract representation to be implemented by arbitrary I/O backends (e.g. MMIO, PCI config space, etc.).
The Io trait provides:
- Base address and size information
- Helper methods for offset validation and address calculation
- Fallible (runtime checked) accessors for different data widths
Which I/O methods are available depends on which IoCapable<T> traits
are implemented for the type.
§Examples
For MMIO regions, all widths (u8, u16, u32, and u64 on 64-bit systems) are typically supported. For PCI configuration space, u8, u16, and u32 are supported but u64 is not.
Required Methods§
Provided Methods§
Sourcefn io_addr<U>(&self, offset: usize) -> Result<usize>
fn io_addr<U>(&self, offset: usize) -> Result<usize>
Returns the absolute I/O address for a given offset,
performing runtime bound checks.
Sourcefn try_read8(&self, _offset: usize) -> Result<u8>
fn try_read8(&self, _offset: usize) -> Result<u8>
Fallible 8-bit read with runtime bounds check.
Sourcefn try_read16(&self, _offset: usize) -> Result<u16>
fn try_read16(&self, _offset: usize) -> Result<u16>
Fallible 16-bit read with runtime bounds check.
Sourcefn try_read32(&self, _offset: usize) -> Result<u32>
fn try_read32(&self, _offset: usize) -> Result<u32>
Fallible 32-bit read with runtime bounds check.
Sourcefn try_read64(&self, _offset: usize) -> Result<u64>
fn try_read64(&self, _offset: usize) -> Result<u64>
Fallible 64-bit read with runtime bounds check.
Sourcefn try_write8(&self, _value: u8, _offset: usize) -> Result
fn try_write8(&self, _value: u8, _offset: usize) -> Result
Fallible 8-bit write with runtime bounds check.
Sourcefn try_write16(&self, _value: u16, _offset: usize) -> Result
fn try_write16(&self, _value: u16, _offset: usize) -> Result
Fallible 16-bit write with runtime bounds check.
Sourcefn try_write32(&self, _value: u32, _offset: usize) -> Result
fn try_write32(&self, _value: u32, _offset: usize) -> Result
Fallible 32-bit write with runtime bounds check.
Sourcefn try_write64(&self, _value: u64, _offset: usize) -> Result
fn try_write64(&self, _value: u64, _offset: usize) -> Result
Fallible 64-bit write with runtime bounds check.
Sourcefn write8(&self, _value: u8, _offset: usize)
fn write8(&self, _value: u8, _offset: usize)
Infallible 8-bit write with compile-time bounds check.
Sourcefn write16(&self, _value: u16, _offset: usize)
fn write16(&self, _value: u16, _offset: usize)
Infallible 16-bit write with compile-time bounds check.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.