#[repr(C, packed(1))]pub struct Opcode {
pub category: u8,
pub command: u8,
pub flags: u16,
pub a: u32,
pub b: u32,
pub c: u32,
}Expand description
A fixed-size 16-byte opcode.
This struct intentionally mirrors the wire layout and is #[repr(C, packed)]
per the specification. Because it is packed, fields may be unaligned; always
read fields through the accessor methods (which use unaligned reads) rather
than by value.
Fields§
§category: u8Opcode category (see constants::Category).
command: u8Command within the category (see constants::Command*).
flags: u16Category/command-specific flags.
a: u32Primary payload.
b: u32Secondary payload.
c: u32Tertiary payload.
Implementations§
Source§impl Opcode
impl Opcode
Sourcepub const fn new(
category: u8,
command: u8,
flags: u16,
a: u32,
b: u32,
c: u32,
) -> Self
pub const fn new( category: u8, command: u8, flags: u16, a: u32, b: u32, c: u32, ) -> Self
Construct an opcode from raw fields.
Sourcepub fn to_bytes(&self) -> [u8; 16]
pub fn to_bytes(&self) -> [u8; 16]
Serialize to the 16-byte wire representation (little-endian).
Sourcepub fn from_bytes(bytes: &[u8; 16]) -> Self
pub fn from_bytes(bytes: &[u8; 16]) -> Self
Deserialize from the 16-byte wire representation (little-endian).
Trait Implementations§
impl Copy for Opcode
impl Eq for Opcode
impl StructuralPartialEq for Opcode
Auto Trait Implementations§
impl Forget for Opcode
impl Freeze for Opcode
impl Move for Opcode
impl RefUnwindSafe for Opcode
impl Send for Opcode
impl Sync for Opcode
impl Unpin for Opcode
impl UnsafeUnpin for Opcode
impl UnwindSafe for Opcode
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