Trait comms_service::LinkPacket
source · [−]pub trait LinkPacket {
fn parse(raw: &[u8]) -> CommsResult<Box<Self>>;
fn build(
command_id: u64,
link_type: PayloadType,
destination_port: u16,
payload: &[u8]
) -> CommsResult<Box<Self>>;
fn to_bytes(&self) -> CommsResult<Vec<u8>>;
fn command_id(&self) -> u64;
fn payload(&self) -> Vec<u8>;
fn payload_type(&self) -> PayloadType;
fn destination(&self) -> u16;
fn validate(&self) -> bool { ... }
fn max_size() -> usize { ... }
}
Expand description
Generic LinkPacket trait which defines the internal packet requirements of the communications service.
Required Methods
fn parse(raw: &[u8]) -> CommsResult<Box<Self>>
fn parse(raw: &[u8]) -> CommsResult<Box<Self>>
Parse packet from raw bytes
fn build(
command_id: u64,
link_type: PayloadType,
destination_port: u16,
payload: &[u8]
) -> CommsResult<Box<Self>>
fn build(
command_id: u64,
link_type: PayloadType,
destination_port: u16,
payload: &[u8]
) -> CommsResult<Box<Self>>
Build packet from necessary parts
fn to_bytes(&self) -> CommsResult<Vec<u8>>
fn to_bytes(&self) -> CommsResult<Vec<u8>>
Create a bytes representation of the packet
fn command_id(&self) -> u64
fn command_id(&self) -> u64
The Command ID of the packet
fn payload_type(&self) -> PayloadType
fn payload_type(&self) -> PayloadType
The type of payload contained in the packet
fn destination(&self) -> u16
fn destination(&self) -> u16
The Destination port of the packet