pub struct EventCommandRef<'a> {
pub code: i32,
pub indent: i32,
pub string: &'a [u8],
/* private fields */
}Expand description
One event command, borrowed from the input buffer.
Fields§
§code: i32The command code.
indent: i32Nesting depth inside conditional branches and loops.
string: &'a [u8]The command’s string operand, verbatim. Never transcoded; see the crate docs.
Implementations§
Source§impl<'a> EventCommandRef<'a>
impl<'a> EventCommandRef<'a>
Sourcepub const fn params(&self) -> ParamIter<'a> ⓘ
pub const fn params(&self) -> ParamIter<'a> ⓘ
Iterate the command’s integer parameters.
Decoded on demand, not collected: most consumers read one or two parameters of the few codes they care about, and never touch the rest.
Sourcepub fn param(&self, index: usize) -> Option<i32>
pub fn param(&self, index: usize) -> Option<i32>
The parameter at index, or None if the command has fewer.
O(index): compressed integers are not fixed width, so there is no direct indexing. Fine
for the small indices real code uses; iterate params for all.
Sourcepub const fn param_count(&self) -> u32
pub const fn param_count(&self) -> u32
How many parameters the command holds. A header declaring more than the payload has room
for reports only those present (plus a DiagKind::ShortChunk),
so this is always safe to size a buffer from.
Sourcepub const fn raw_params(&self) -> &'a [u8] ⓘ
pub const fn raw_params(&self) -> &'a [u8] ⓘ
The undecoded parameter bytes.
For carrying the parameters somewhere before decoding them. The C API returns this span so
rm2k_event_command_param can decode on demand without keeping the iterator alive.