macro_rules! io_project {
($io:expr, try: $ioloc:expr) => { ... };
($io:expr, build: $ioloc:expr) => { ... };
($io:expr, $($proj:tt)*) => { ... };
}Expand description
Project an I/O type to a subview of it.
The syntax is of form io_project!(io, proj) where io is an expression to a type that
implements Io and proj is a projection specification.
io_project! can also project to a subview of registers defined with register! macro.
Register projection has syntax io_project!(io, try: REGISTER) for fallible projection and
io_project!(io, build: REGISTER) for infallible projection.
ยงExamples
use kernel::io::{
io_project,
register,
Mmio,
};
#[repr(C)]
struct MyStruct { field: u32, }
register! {
base: MyStruct;
FIELD(u32) @ 0 {
31:0 val;
}
}
// let mmio: Mmio<[MyStruct]>;
let field: Mmio<'_, u32> = io_project!(mmio, [try: 1].field);
let whole: Mmio<'_, MyStruct> = io_project!(mmio, [try: 2]);
let nested: Mmio<'_, u32> = io_project!(whole, .field);
let reg: Mmio<'_, FIELD> = io_project!(whole, build: FIELD);