serde/
ignore.rs

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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use crate::{de::Deserialize, visitor::Visitor};

/// Allow to ignore any value for deserialization.
pub struct Ignore;

impl Visitor for Ignore {
    type Value = Ignore;

    fn expected(&self) -> &'static str {
        "ignore anything"
    }

    fn visit_unit(self) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_bool(self, _value: bool) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_u128(self, _value: u128) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_i128(self, _value: i128) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_f64(self, _value: f64) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_char(self, _value: char) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_string(self, _value: String) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_none(self) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_some<D: crate::de::Deserializer>(
        self,
        deserializer: D,
    ) -> Result<Self::Value, crate::de::Error> {
        deserializer.deserialize_any(Ignore)
    }

    fn visit_seq<Seq: crate::visitor::SeqAccess>(
        self,
        _seq: Seq,
    ) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_bytes_buf(self, _bytes: Vec<u8>) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_map<Map: crate::visitor::MapAccess>(
        self,
        _map: Map,
    ) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }

    fn visit_bytes_seq<B: crate::visitor::BytesAccess>(
        self,
        _bytes: B,
    ) -> Result<Self::Value, crate::de::Error> {
        Ok(Ignore)
    }
}

impl Deserialize for Ignore {
    fn deserialize<D: crate::de::Deserializer>(deserializer: D) -> Result<Self, crate::de::Error> {
        deserializer.deserialize_any(Ignore)
    }
}