pub struct Packet<'a> {
pub header: &'a Header,
pub payload: &'a [u8],
}
Expand description
A typed reference to the contents of a packet in a buffer.
Fields§
§header: &'a Header
The packet’s header
payload: &'a [u8]
The packet’s payload
Implementations§
Source§impl<'a> Packet<'a>
impl<'a> Packet<'a>
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
The size of this packet according to its header (as Self::payload
may have been
over-allocated for the size of the packet).
Sourcepub fn write_to_unchecked(&'a self, buf: &'a mut [u8]) -> &'a mut [u8] ⓘ
pub fn write_to_unchecked(&'a self, buf: &'a mut [u8]) -> &'a mut [u8] ⓘ
Writes the packet to a buffer when the buffer is known to be large enough to hold it. Note
that the packet header’s Header::payload_len
must be correct before calling this, it
does not use the size of Self::payload
to decide how much of the payload buffer is
valid.
§Panics
Panics if the buffer is not large enough for the packet.
Trait Implementations§
Source§impl<'a> Ord for Packet<'a>
impl<'a> Ord for Packet<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for Packet<'a>
impl<'a> PartialOrd for Packet<'a>
impl<'a> Eq for Packet<'a>
impl<'a> StructuralPartialEq for Packet<'a>
Auto Trait Implementations§
impl<'a> Freeze for Packet<'a>
impl<'a> RefUnwindSafe for Packet<'a>
impl<'a> Send for Packet<'a>
impl<'a> Sync for Packet<'a>
impl<'a> Unpin for Packet<'a>
impl<'a> UnwindSafe for Packet<'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