pub trait Codec<T> {
    type Error: Debug + Display + Send + Sync + 'static;

    fn encode_header(
        &mut self,
        header: &Header<T>,
        buf: impl BufMut
    ) -> Result<(), Self::Error>; fn decode_header(&mut self, buf: impl Buf) -> Result<Header<T>, Self::Error>; fn encode_member(
        &mut self,
        member: &Member<T>,
        buf: impl BufMut
    ) -> Result<(), Self::Error>; fn decode_member(&mut self, buf: impl Buf) -> Result<Member<T>, Self::Error>; }
Expand description

A Codec is responsible to encoding and decoding the data that is sent between cluster members.

So you can paint your bike shed however you like.

Required Associated Types

The codec error type. Will be wrapped by crate::Error.

Required Methods

Encodes a foca::Header into the given buffer.

Decode a Header from the given buffer.

Implementations MUST read a single item from the buffer and advance the cursor accordingly.

Implementations may assume the data in the buffer is contiguous.

Encodes a Member into the given buffer.

Implementations MUST NOT leave the buffer dirty when there’s not enough space to encode the item.

Decode a Member from the given buffer.

Implementations MUST read a single item from the buffer and advance the cursor accordingly.

Implementations may assume the data in the buffer is contiguous.

Implementations on Foreign Types

Implementors