PacketParse

Trait PacketParse 

Source
pub trait PacketParse: Sized {
    // Required method
    fn parse(bytes: &[u8]) -> Result<Self, CommunicationError>;
}
Expand description

Trait for packet parsing

Implemented by packet types that can be deserialized from received bytes. The input bytes should contain only the payload data, with the protocol header already processed and removed.

Required Methods§

Source

fn parse(bytes: &[u8]) -> Result<Self, CommunicationError>

Parses bytes into a packet instance

§Arguments
  • bytes - Raw payload bytes (without protocol header)
§Returns

A Result containing the parsed packet or an error

§Errors

If bytes contains improper data for current packet.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§