pub trait Codec<T> {
type Error: Debug + Display + Send + Sync + 'static;
// Required methods
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§
Required Methods§
sourcefn encode_header(
&mut self,
header: &Header<T>,
buf: impl BufMut
) -> Result<(), Self::Error>
fn encode_header( &mut self, header: &Header<T>, buf: impl BufMut ) -> Result<(), Self::Error>
Encodes a foca::Header
into the given buffer.
sourcefn decode_header(&mut self, buf: impl Buf) -> Result<Header<T>, Self::Error>
fn decode_header(&mut self, buf: impl Buf) -> Result<Header<T>, Self::Error>
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.
Object Safety§
This trait is not object safe.