codee/
traits.rs

1/// Trait every encoder must implement.
2pub trait Encoder<T>: 'static {
3    type Error;
4    type Encoded;
5
6    fn encode(val: &T) -> Result<Self::Encoded, Self::Error>;
7}
8
9/// Trait every decoder must implement.
10pub trait Decoder<T>: 'static {
11    type Error;
12    type Encoded: ?Sized;
13
14    fn decode(val: &Self::Encoded) -> Result<T, Self::Error>;
15}