Skip to main content

IoLoc

Trait IoLoc 

Source
pub trait IoLoc<Base: ?Sized, T> {
    // Required method
    fn offset(self) -> usize;
}
Expand description

Describes a given I/O location: its offset, width, and type to convert the raw value from and into.

This trait is the key abstraction allowing Io::read, Io::write, and Io::update (and their fallible try_read, try_write and try_update counterparts) to work uniformly with both raw usize offsets (for primitive types like u32) and typed ones (like those generated by the register! macro).

An IoLoc<Base, T> carries the following pieces of information:

  • The valid Base to operate on. For most registers, this should be Region.
  • The offset to access (returned by IoLoc::offset),
  • The type T in which the data is returned or provided.

T is not necessarily the type for underlying I/O operation. Methods that take IoLoc have T: AsRepr bound and the <T as AsRepr>::Repr type would be used to perform I/O and converted to T instead.

Required Methods§

Source

fn offset(self) -> usize

Consumes self and returns the offset of this location.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<Base: ?Sized, T> IoLoc<Base, T> for ()
where T: FixedIoLoc<Base>,

Allows () to be used as the location parameter of Io::write when passing a FixedIoLoc value.

Source§

fn offset(self) -> usize

Source§

impl<const SIZE: usize> IoLoc<Region<SIZE>, u8> for usize

Source§

fn offset(self) -> usize

Source§

impl<const SIZE: usize> IoLoc<Region<SIZE>, u16> for usize

Source§

fn offset(self) -> usize

Source§

impl<const SIZE: usize> IoLoc<Region<SIZE>, u32> for usize

Source§

fn offset(self) -> usize

Source§

impl<const SIZE: usize> IoLoc<Region<SIZE>, u64> for usize

Source§

fn offset(self) -> usize

Implementors§

Source§

impl<Base: ?Sized, T> IoLoc<Base, T> for RegisterArrayLoc<T>
where T: RegisterArray<Base = Base>,