#[repr(C)]pub struct Packet { /* private fields */ }
Implementations§
Source§impl Packet
impl Packet
pub fn new(buffer: [u8; 1232], meta: Meta) -> Self
Sourcepub fn data<I>(&self, index: I) -> Option<&<I as SliceIndex<[u8]>>::Output>where
I: SliceIndex<[u8]>,
pub fn data<I>(&self, index: I) -> Option<&<I as SliceIndex<[u8]>>::Output>where
I: SliceIndex<[u8]>,
Returns an immutable reference to the underlying buffer up to packet.meta.size. The rest of the buffer is not valid to read from. packet.data(..) returns packet.buffer.get(..packet.meta.size). Returns None if the index is invalid or if the packet is already marked as discard.
Sourcepub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
pub fn buffer_mut(&mut self) -> &mut [u8] ⓘ
Returns a mutable reference to the entirety of the underlying buffer to write into. The caller is responsible for updating Packet.meta.size after writing to the buffer.
pub fn meta(&self) -> &Meta
pub fn meta_mut(&mut self) -> &mut Meta
pub fn from_data<T: Serialize>( dest: Option<&SocketAddr>, data: T, ) -> Result<Self>
Available on crate feature
bincode
only.pub fn populate_packet<T: Serialize>( &mut self, dest: Option<&SocketAddr>, data: &T, ) -> Result<()>
Available on crate feature
bincode
only.pub fn deserialize_slice<T, I>(&self, index: I) -> Result<T>
Available on crate feature
bincode
only.Trait Implementations§
Source§impl<'de> Deserialize<'de> for Packet
impl<'de> Deserialize<'de> for Packet
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Packet
Auto Trait Implementations§
impl Freeze for Packet
impl RefUnwindSafe for Packet
impl Send for Packet
impl Sync for Packet
impl Unpin for Packet
impl UnwindSafe for Packet
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more