Skip to main content

IoLoc

Trait IoLoc 

Source
pub trait IoLoc<T> {
    type IoType: Into<T> + From<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<T> carries three pieces of information:

  • The offset to access (returned by IoLoc::offset),
  • The width of the access (determined by IoLoc::IoType),
  • The type T in which the raw data is returned or provided.

T and IoLoc::IoType may differ: for instance, a typed register has T = the register type with its bitfields, and IoType = its backing primitive (e.g. u32).

Required Associated Types§

Source

type IoType: Into<T> + From<T>

Size (u8, u16, etc) of the I/O performed on the returned offset.

Required Methods§

Source

fn offset(self) -> usize

Consumes self and returns the offset of this location.

Implementations on Foreign Types§

Source§

impl IoLoc<u8> for usize

Source§

impl IoLoc<u16> for usize

Source§

impl IoLoc<u32> for usize

Source§

impl IoLoc<u64> for usize

Source§

impl<T> IoLoc<T> for ()
where T: FixedRegister,

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

Implementors§

Source§

impl<T> IoLoc<T> for FixedRegisterLoc<T>
where T: FixedRegister,

Source§

impl<T> IoLoc<T> for RegisterArrayLoc<T>
where T: RegisterArray,

Source§

impl<T> IoLoc<T> for T
where T: FixedRegister,

A FixedRegister carries its location in its type. Thus FixedRegister values can be used as an IoLoc.

Source§

impl<T, B> IoLoc<T> for RelativeRegisterArrayLoc<T, B>

Source§

impl<T, B> IoLoc<T> for RelativeRegisterLoc<T, B>