Struct sermux_proto::PortChunk
source · pub struct PortChunk<'a> {
pub port: u16,
pub chunk: &'a [u8],
}
Fields§
§port: u16
§chunk: &'a [u8]
Implementations§
source§impl<'a> PortChunk<'a>
impl<'a> PortChunk<'a>
sourcepub fn new(port: impl Into<u16>, chunk: &'a [u8]) -> Self
pub fn new(port: impl Into<u16>, chunk: &'a [u8]) -> Self
Create a new PortChunk from the given port and data
sourcepub fn buffer_required(&self) -> usize
pub fn buffer_required(&self) -> usize
Calculate the size required to encode the given data payload size
sourcepub fn encode_to<'b>(
&self,
out_buf: &'b mut [u8],
) -> Result<&'b mut [u8], EncodeError>
pub fn encode_to<'b>( &self, out_buf: &'b mut [u8], ) -> Result<&'b mut [u8], EncodeError>
Encodes the current PortChunk into the given buffer
sourcepub fn decode_from(data: &'a mut [u8]) -> Result<Self, DecodeError>
pub fn decode_from(data: &'a mut [u8]) -> Result<Self, DecodeError>
Decodes a PortChunk from the given buffer
NOTE: This MAY mutate data
, even if the decoding fails.
sourcepub fn into_owned(self) -> OwnedPortChunk
pub fn into_owned(self) -> OwnedPortChunk
Convert into an OwnedPortChunk
Only available with the use-std
feature active
Trait Implementations§
impl<'a> StructuralPartialEq for PortChunk<'a>
Auto Trait Implementations§
impl<'a> Freeze for PortChunk<'a>
impl<'a> RefUnwindSafe for PortChunk<'a>
impl<'a> Send for PortChunk<'a>
impl<'a> Sync for PortChunk<'a>
impl<'a> Unpin for PortChunk<'a>
impl<'a> UnwindSafe for PortChunk<'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