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.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.