pub struct PacketMut<'a> {
pub header: &'a mut Header,
pub payload: &'a mut [u8],
}
Expand description
A typed mutable reference to the contents of a packet in a buffer.
Fields§
§header: &'a mut Header
The packet’s header.
payload: &'a mut [u8]
The packet’s payload.
Implementations§
Source§impl<'a> PacketMut<'a>
impl<'a> PacketMut<'a>
Sourcepub fn new_in(packet_type: PacketType, buf: &'a mut [u8]) -> Self
pub fn new_in(packet_type: PacketType, buf: &'a mut [u8]) -> Self
Creates a new PacketMut
inside the given buffer and initializes the header to the given
PacketType
before returning it. All other fields in the header will be zeroed, and the
PacketMut::payload
will be the remaining area of the buffer after the header.
Use PacketMut::finish
to validate and write the proper packet length and return the
total size of the packet.
§Panics
The buffer must be large enough to hold at least a packet header, and this will panic if it’s not.
Trait Implementations§
Source§impl<'a> Ord for PacketMut<'a>
impl<'a> Ord for PacketMut<'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 PacketMut<'a>
impl<'a> PartialOrd for PacketMut<'a>
impl<'a> Eq for PacketMut<'a>
impl<'a> StructuralPartialEq for PacketMut<'a>
Auto Trait Implementations§
impl<'a> Freeze for PacketMut<'a>
impl<'a> RefUnwindSafe for PacketMut<'a>
impl<'a> Send for PacketMut<'a>
impl<'a> Sync for PacketMut<'a>
impl<'a> Unpin for PacketMut<'a>
impl<'a> !UnwindSafe for PacketMut<'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