pub enum Packet<'a> {
Connless(&'a [u8]),
Connected(ConnectedPacket<'a>),
}Variants§
Connless(&'a [u8])
Connected(ConnectedPacket<'a>)
Implementations§
Source§impl<'a> Packet<'a>
impl<'a> Packet<'a>
pub fn is_initial(packet: &[u8]) -> bool
Sourcepub fn read<'b, B, W>(
warn: &mut W,
bytes: &'b [u8],
token_hint: Option<bool>,
buffer: B,
) -> Result<Packet<'b>, PacketReadError>
pub fn read<'b, B, W>( warn: &mut W, bytes: &'b [u8], token_hint: Option<bool>, buffer: B, ) -> Result<Packet<'b>, PacketReadError>
Parse a packet.
token_hint tells the decoder whether to expect a DDNet 0.6-style
token. If you call this as part of an existing connection, pass
Some(bool) to tell whether this connection uses the token. If you
call this on a packet not associated to a connection, use None.
buffer needs to have at least size MAX_PAYLOAD.
pub fn read_panic_on_decompression<'b, W>( warn: &mut W, bytes: &'b [u8], token_hint: Option<bool>, ) -> Result<Packet<'b>, PacketReadError>
Sourcepub fn decompress_if_needed<B: Buffer<'a>>(
packet: &[u8],
buffer: B,
) -> Result<bool, DecompressionError>
pub fn decompress_if_needed<B: Buffer<'a>>( packet: &[u8], buffer: B, ) -> Result<bool, DecompressionError>
buffer needs to have at least size MAX_PACKETSIZE.
pub fn write<'b, B: Buffer<'b>>(&self, buffer: B) -> Result<&'b [u8], Error>
Trait Implementations§
impl<'a> Copy 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> UnsafeUnpin 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