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

Encodes a message into a buffer. Lcm uses a Vec<u8> with its capacity set to the value returned by [size()].

Decodes a message from a buffer.

Returns the number of bytes this message is expected to take when encoded.

Provided Methods

Encodes a message into a buffer, with the message hash at the beginning.

Decodes a message from a buffer, and also checks that the hash at the beginning is correct.

Returns the message hash for this type. Returns 0 for all primitive types. Generated Lcm types should implement this function.

Implementors