macro_rules! io_define_write {
(infallible, $(#[$attr:meta])* $vis:vis $name:ident, $call_macro:ident($c_fn:ident) <-
$type_name:ty) => { ... };
(fallible, $(#[$attr:meta])* $vis:vis $try_name:ident, $call_macro:ident($c_fn:ident) <-
$type_name:ty) => { ... };
}Expand description
Generates an accessor method for writing to an I/O backend.
This macro reduces boilerplate by automatically generating either compile-time bounds-checked (infallible) or runtime bounds-checked (fallible) write methods. It abstracts the address calculation and bounds checking, and delegates the actual I/O write operation to a specified helper macro, making it generic over different I/O backends.
ยงParameters
infallible/fallible- Determines the bounds-checking strategy.infalliblerelies onIoKnownSizefor compile-time checks and returns().fallibleperforms runtime checks againstmaxsize()and returns aResult.$(#[$attr:meta])*- Optional attributes to apply to the generated method (e.g.,#[cfg(CONFIG_64BIT)]or inline directives).$vis:vis- The visibility of the generated method (e.g.,pub).$name:ident/$try_name:ident- The name of the generated method (e.g.,write32,try_write8).$call_macro:ident- The backend-specific helper macro used to emit the actual I/O call (e.g.,call_mmio_write).$c_fn:ident- The backend-specific C function or identifier to be passed into the$call_macro.$type_name:ty- The Rust type of the value being written (e.g.,u8,u32). Note the use of<-before the type to denote a write operation.