Skip to main content

Io

Trait Io 

Source
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§

Source

fn addr(&self) -> usize

Returns the base address of this mapping.

Source

fn maxsize(&self) -> usize

Returns the maximum size of this mapping.

Provided Methods§

Source

fn io_addr<U>(&self, offset: usize) -> Result<usize>

Returns the absolute I/O address for a given offset, performing runtime bound checks.

Source

fn try_read8(&self, _offset: usize) -> Result<u8>
where Self: IoCapable<u8>,

Fallible 8-bit read with runtime bounds check.

Source

fn try_read16(&self, _offset: usize) -> Result<u16>
where Self: IoCapable<u16>,

Fallible 16-bit read with runtime bounds check.

Source

fn try_read32(&self, _offset: usize) -> Result<u32>
where Self: IoCapable<u32>,

Fallible 32-bit read with runtime bounds check.

Source

fn try_read64(&self, _offset: usize) -> Result<u64>
where Self: IoCapable<u64>,

Fallible 64-bit read with runtime bounds check.

Source

fn try_write8(&self, _value: u8, _offset: usize) -> Result
where Self: IoCapable<u8>,

Fallible 8-bit write with runtime bounds check.

Source

fn try_write16(&self, _value: u16, _offset: usize) -> Result
where Self: IoCapable<u16>,

Fallible 16-bit write with runtime bounds check.

Source

fn try_write32(&self, _value: u32, _offset: usize) -> Result
where Self: IoCapable<u32>,

Fallible 32-bit write with runtime bounds check.

Source

fn try_write64(&self, _value: u64, _offset: usize) -> Result
where Self: IoCapable<u64>,

Fallible 64-bit write with runtime bounds check.

Source

fn read8(&self, _offset: usize) -> u8
where Self: IoKnownSize + IoCapable<u8>,

Infallible 8-bit read with compile-time bounds check.

Source

fn read16(&self, _offset: usize) -> u16
where Self: IoKnownSize + IoCapable<u16>,

Infallible 16-bit read with compile-time bounds check.

Source

fn read32(&self, _offset: usize) -> u32
where Self: IoKnownSize + IoCapable<u32>,

Infallible 32-bit read with compile-time bounds check.

Source

fn read64(&self, _offset: usize) -> u64
where Self: IoKnownSize + IoCapable<u64>,

Infallible 64-bit read with compile-time bounds check.

Source

fn write8(&self, _value: u8, _offset: usize)
where Self: IoKnownSize + IoCapable<u8>,

Infallible 8-bit write with compile-time bounds check.

Source

fn write16(&self, _value: u16, _offset: usize)
where Self: IoKnownSize + IoCapable<u16>,

Infallible 16-bit write with compile-time bounds check.

Source

fn write32(&self, _value: u32, _offset: usize)
where Self: IoKnownSize + IoCapable<u32>,

Infallible 32-bit write with compile-time bounds check.

Source

fn write64(&self, _value: u64, _offset: usize)
where Self: IoKnownSize + IoCapable<u64>,

Infallible 64-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.

Implementors§

Source§

impl<'a, S: ConfigSpaceKind> Io for ConfigSpace<'a, S>

Source§

impl<const SIZE: usize> Io for Mmio<SIZE>