#[non_exhaustive]pub struct LayoutDef {
pub name: String,
pub container: Container,
pub fields: Vec<Field>,
pub view: bool,
pub truncate: bool,
pub doc: Option<String>,
pub derives: Vec<Derive>,
}Expand description
A fixed-size layout whose fields cover every bit of its container.
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.
container: ContainerThe container.
fields: Vec<Field>The fields, in wire order.
view: boolWhether to generate a <Name>View that reads fields in place: #[layout(.., view)].
truncate: boolWhether encode keeps the low bits of a value wider than its field instead of panicking:
#[layout(.., truncate)].
doc: Option<String>Documentation.
derives: Vec<Derive>Derives for this layout, written after the module’s.
Implementations§
Source§impl LayoutDef
impl LayoutDef
Sourcepub fn new(name: &str, container: Container, fields: Vec<Field>) -> Self
pub fn new(name: &str, container: Container, fields: Vec<Field>) -> Self
A layout with no view.
Sourcepub fn with_derives(self, derives: Vec<Derive>) -> Self
pub fn with_derives(self, derives: Vec<Derive>) -> Self
Sets the derives written on this layout, after the module’s.
Sourcepub fn with_truncate(self) -> Self
pub fn with_truncate(self) -> Self
Makes encode keep the low bits of a value wider than its field, as a hardware register does.
Trait Implementations§
impl Eq for LayoutDef
impl StructuralPartialEq for LayoutDef
Auto Trait Implementations§
impl Freeze for LayoutDef
impl RefUnwindSafe for LayoutDef
impl Send for LayoutDef
impl Sync for LayoutDef
impl Unpin for LayoutDef
impl UnsafeUnpin for LayoutDef
impl UnwindSafe for LayoutDef
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