pub trait Message {
// Required methods
fn encode(&self, buffer: &mut dyn Write) -> Result<()>;
fn decode(buffer: &mut dyn Read) -> Result<Self>
where Self: Sized;
fn size(&self) -> usize;
// Provided methods
fn encode_with_hash(&self) -> Result<Vec<u8>>
where Self: Sized { ... }
fn decode_with_hash(buffer: &mut dyn Read) -> Result<Self>
where Self: Sized { ... }
fn hash() -> u64
where Self: Sized { ... }
}
Expand description
A message that can be encoded and decoded according to the LCM protocol.
Required Methods§
Sourcefn encode(&self, buffer: &mut dyn Write) -> Result<()>
fn encode(&self, buffer: &mut dyn Write) -> Result<()>
Encodes a message into a buffer.
Lcm
uses a Vec<u8>
with its capacity set to the value returned by [size()
].
Provided Methods§
Sourcefn encode_with_hash(&self) -> Result<Vec<u8>>where
Self: Sized,
fn encode_with_hash(&self) -> Result<Vec<u8>>where
Self: Sized,
Encodes a message into a buffer, with the message hash at the beginning.
Sourcefn decode_with_hash(buffer: &mut dyn Read) -> Result<Self>where
Self: Sized,
fn decode_with_hash(buffer: &mut dyn Read) -> Result<Self>where
Self: Sized,
Decodes a message from a buffer, and also checks that the hash at the beginning is correct.