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
53
54
55
56
57
58
59
60
61
mod decoder;
mod error;
use crate::filler::Filler;
pub use decoder::Decoder;
pub use error::Error;
pub trait Decode<'b>: Sized {
fn decode(d: &mut Decoder) -> Result<Self, Error>;
}
impl Decode<'_> for Filler {
fn decode(d: &mut Decoder) -> Result<Filler, Error> {
d.filler()?;
Ok(Filler::FillerEnd)
}
}
impl Decode<'_> for Vec<u8> {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.bytes()
}
}
impl Decode<'_> for u8 {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.u8()
}
}
impl Decode<'_> for isize {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.integer()
}
}
impl Decode<'_> for usize {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.word()
}
}
impl Decode<'_> for char {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.char()
}
}
impl Decode<'_> for String {
fn decode(d: &mut Decoder) -> Result<Self, Error> {
d.utf8()
}
}
impl Decode<'_> for bool {
fn decode(d: &mut Decoder) -> Result<bool, Error> {
d.bool()
}
}