1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
mod encoder;
mod impl_tuples;
mod impls;
use self::write::Writer;
use crate::{config::Config, error::EncodeError, utils::Sealed};
pub mod write;
pub use self::encoder::EncoderImpl;
pub trait Encode {
fn encode<E: Encoder>(&self, encoder: E) -> Result<(), EncodeError>;
}
pub trait Encoder: Sealed {
type W: Writer;
type C: Config;
fn writer(&mut self) -> &mut Self::W;
fn config(&self) -> &Self::C;
}
impl<'a, T> Encoder for &'a mut T
where
T: Encoder,
{
type W = T::W;
type C = T::C;
fn writer(&mut self) -> &mut Self::W {
T::writer(self)
}
fn config(&self) -> &Self::C {
T::config(self)
}
}