Trait lcm::Message
[−]
[src]
pub trait Message { fn encode(&self, buffer: &mut Write) -> Result<()>; fn decode(buffer: &mut Read) -> Result<Self>
where
Self: Sized; fn size(&self) -> usize; fn encode_with_hash(&self) -> Result<Vec<u8>>
where
Self: Sized, { ... } fn decode_with_hash(buffer: &mut Read) -> Result<Self>
where
Self: Sized, { ... } fn hash() -> u64
where
Self: Sized, { ... } }
A message that can be encoded and decoded according to the LCM protocol.
Required Methods
fn encode(&self, buffer: &mut Write) -> Result<()>
Encodes a message into a buffer.
Lcm
uses a Vec<u8>
with its capacity set to the value returned by [size()
].
fn decode(buffer: &mut Read) -> Result<Self> where
Self: Sized,
Self: Sized,
Decodes a message from a buffer.
fn size(&self) -> usize
Returns the number of bytes this message is expected to take when encoded.
Provided Methods
fn encode_with_hash(&self) -> Result<Vec<u8>> where
Self: Sized,
Self: Sized,
Encodes a message into a buffer, with the message hash at the beginning.
fn decode_with_hash(buffer: &mut Read) -> Result<Self> where
Self: Sized,
Self: Sized,
Decodes a message from a buffer, and also checks that the hash at the beginning is correct.
fn hash() -> u64 where
Self: Sized,
Self: Sized,
Returns the message hash for this type.
Returns 0
for all primitive types.
Generated Lcm
types should implement this function.