concision_core/traits/codex.rs
1/*
2 appellation: codex <module>
3 authors: @FL03
4*/
5/// [Decode] defines a standard interface for decoding data.
6pub trait Decode<Rhs> {
7 type Output;
8
9 fn decode(values: Rhs) -> Self::Output;
10}
11
12/// [Encode] defines a standard interface for encoding data.
13pub trait Encode<Rhs> {
14 type Output;
15
16 fn encode(&self, values: Rhs) -> Self::Output;
17}
18
19pub trait Codex<A, B> {
20 type Encoder<U, V>: Encode<U, Output = V>;
21 type Decoder<U, V>: Decode<U, Output = V>;
22
23 fn encode(&self) -> Self::Encoder<A, B>;
24
25 fn decode() -> Self::Decoder<B, A>;
26}