pub struct PacketView<'a> { /* private fields */ }Expand description
A zero-copy view into a raw packet buffer.
PacketView does not own the underlying data. It simply interprets a
byte slice according to the expected packet layout.
This is useful in embedded or no_std environments where copying or
allocating packets is undesirable.
§Packet layout
The expected layout of the underlying buffer is assumed to be:
+----------------+----------------+----------------+
| MAC (6 bytes) | FLAGS (1 byte) | NONCE (5 bytes) | ...
+----------------+----------------+----------------+Offsets are defined by constants such as MAC_OFFSET, FLAGS_IDX,
and NONCE_OFFSET.
§Safety / Panics
This type uses unwrap() internally when extracting fixed-size fields.
Therefore:
- The input slice must be large enough
- Invalid or truncated buffers will cause a panic
In embedded contexts, ensure packet validation happens before constructing
a PacketView.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for PacketView<'a>
impl<'a> RefUnwindSafe for PacketView<'a>
impl<'a> Send for PacketView<'a>
impl<'a> Sync for PacketView<'a>
impl<'a> Unpin for PacketView<'a>
impl<'a> UnsafeUnpin for PacketView<'a>
impl<'a> UnwindSafe for PacketView<'a>
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