1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/// Trait every encoder must implement.
pub trait Encoder<T>: 'static {
    type Error;
    type Encoded;

    fn encode(val: &T) -> Result<Self::Encoded, Self::Error>;
}

/// Trait every decoder must implement.
pub trait Decoder<T>: 'static {
    type Error;
    type Encoded: ?Sized;

    fn decode(val: &Self::Encoded) -> Result<T, Self::Error>;
}