#[non_exhaustive]pub struct ChoiceDef {
pub name: String,
pub endian: Endian,
pub arms: Vec<Arm>,
pub other: Option<String>,
pub other_bytes: Option<usize>,
pub doc: Option<String>,
}Expand description
The arms of a Segment::Switch.
With a fallback other variant, an unmatched value keeps its bytes: the rest of
the body, or other_bytes of them.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringThe type name.
endian: EndianByte order of the arms’ fields.
arms: Vec<Arm>The arms, in declaration order.
other: Option<String>The fallback variant for an unmatched value. None makes it a decode error.
other_bytes: Option<usize>The fallback’s size in bytes, when the choice is a union.
None takes the rest of the body, so no field can follow the switch.
doc: Option<String>Documentation.
Implementations§
Source§impl ChoiceDef
impl ChoiceDef
Sourcepub fn with_endian(self, endian: Endian) -> Self
pub fn with_endian(self, endian: Endian) -> Self
Sets the byte order.
Sourcepub fn with_other(self, other: &str) -> Self
pub fn with_other(self, other: &str) -> Self
Adds a fallback variant that keeps an unmatched value’s bytes.
Sourcepub fn with_other_bytes(self, bytes: usize) -> Self
pub fn with_other_bytes(self, bytes: usize) -> Self
Makes the choice a union of bytes bytes.
Every arm must fill exactly that size, and a field can follow the switch.
Sourcepub fn open_ended(&self) -> bool
pub fn open_ended(&self) -> bool
Whether the choice reads to the end of the body.
True when any arm does, or when the fallback has no fixed size.
Trait Implementations§
impl Eq for ChoiceDef
impl StructuralPartialEq for ChoiceDef
Auto Trait Implementations§
impl Freeze for ChoiceDef
impl RefUnwindSafe for ChoiceDef
impl Send for ChoiceDef
impl Sync for ChoiceDef
impl Unpin for ChoiceDef
impl UnsafeUnpin for ChoiceDef
impl UnwindSafe for ChoiceDef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more