Macro cdragon_prop::binget
source · macro_rules! binget { ($e:expr => $($tail:tt)*) => { ... }; ($e:expr, ) => { ... }; ($e:expr, . $($tail:tt)*) => { ... }; ($e:expr, $f:ident($t:ty) $($tail:tt)*) => { ... }; ($e:expr, $x:literal($t:ty) $($tail:tt)*) => { ... }; ($e:expr, ($t:ty) $($tail:tt)*) => { ... }; ($e:expr, ($k:ty, $v:ty) $($tail:tt)*) => { ... }; }
Expand description
Helper to access nested bin values
First parameter is the top-level bin value to access. Second parameter is the sequence of items to access. Elements must be properly downcasted by indicating the type when needed (in brackets).
Return an Option
.
Examples
// Get an entry field value
binget!(entry => mName(BinString));
// Access content of a list field
binget!(entry => mNames(BinList)(BinString));
// Chained field access
binget!(entry => mData(BinStruct).mValue(BinU32));
// Access field from hash integer value
binget!(entry => 0x12345678(BinString));
// Access entries of a `BinMap`
binget!(map => (BinHash, BinLink));