Skip to content

Commit 1c65f31

Browse files
authored
Merge pull request #5 from woshiluo/patch-2
fix: too early drop_on
2 parents aadf69a + ae81000 commit 1c65f31

File tree

3 files changed

+279
-270
lines changed

3 files changed

+279
-270
lines changed

src/de_mut/group.rs

Lines changed: 251 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,251 @@
1+
use super::{DtError, GroupCursor, RefDtb, RegConfig};
2+
use serde::de;
3+
4+
#[allow(unused)]
5+
#[derive(Clone, Copy)]
6+
pub(super) struct GroupDeserializer<'de> {
7+
pub dtb: RefDtb<'de>,
8+
pub cursor: GroupCursor,
9+
pub reg: RegConfig,
10+
pub len_item: usize,
11+
pub len_name: usize,
12+
}
13+
14+
impl<'de, 'b> de::Deserializer<'de> for &'b mut GroupDeserializer<'de> {
15+
type Error = DtError;
16+
17+
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
18+
where
19+
V: de::Visitor<'de>,
20+
{
21+
todo!("any")
22+
}
23+
24+
fn deserialize_bool<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
25+
where
26+
V: de::Visitor<'de>,
27+
{
28+
todo!("bool")
29+
}
30+
31+
fn deserialize_i8<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
32+
where
33+
V: de::Visitor<'de>,
34+
{
35+
todo!("i8")
36+
}
37+
38+
fn deserialize_i16<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
39+
where
40+
V: de::Visitor<'de>,
41+
{
42+
todo!("i16")
43+
}
44+
45+
fn deserialize_i32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
46+
where
47+
V: de::Visitor<'de>,
48+
{
49+
todo!("i32")
50+
}
51+
52+
fn deserialize_i64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
53+
where
54+
V: de::Visitor<'de>,
55+
{
56+
todo!("i64")
57+
}
58+
59+
fn deserialize_u8<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
60+
where
61+
V: de::Visitor<'de>,
62+
{
63+
todo!("u8")
64+
}
65+
66+
fn deserialize_u16<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
67+
where
68+
V: de::Visitor<'de>,
69+
{
70+
todo!("u16")
71+
}
72+
73+
fn deserialize_u32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
74+
where
75+
V: de::Visitor<'de>,
76+
{
77+
todo!("u32")
78+
}
79+
80+
fn deserialize_u64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
81+
where
82+
V: de::Visitor<'de>,
83+
{
84+
todo!("u64")
85+
}
86+
87+
fn deserialize_f32<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
88+
where
89+
V: de::Visitor<'de>,
90+
{
91+
todo!("f32")
92+
}
93+
94+
fn deserialize_f64<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
95+
where
96+
V: de::Visitor<'de>,
97+
{
98+
todo!("f64")
99+
}
100+
101+
fn deserialize_char<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
102+
where
103+
V: de::Visitor<'de>,
104+
{
105+
todo!("char")
106+
}
107+
108+
fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
109+
where
110+
V: de::Visitor<'de>,
111+
{
112+
todo!("str")
113+
}
114+
115+
fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
116+
where
117+
V: de::Visitor<'de>,
118+
{
119+
todo!("string")
120+
}
121+
122+
fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
123+
where
124+
V: de::Visitor<'de>,
125+
{
126+
todo!("bytes")
127+
}
128+
129+
fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
130+
where
131+
V: de::Visitor<'de>,
132+
{
133+
todo!("byte_buf")
134+
}
135+
136+
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
137+
where
138+
V: de::Visitor<'de>,
139+
{
140+
visitor.visit_some(self)
141+
}
142+
143+
fn deserialize_unit<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
144+
where
145+
V: de::Visitor<'de>,
146+
{
147+
todo!("unit")
148+
}
149+
150+
fn deserialize_unit_struct<V>(
151+
self,
152+
_name: &'static str,
153+
_visitor: V,
154+
) -> Result<V::Value, Self::Error>
155+
where
156+
V: de::Visitor<'de>,
157+
{
158+
todo!("unit_struct")
159+
}
160+
161+
fn deserialize_newtype_struct<V>(
162+
self,
163+
name: &'static str,
164+
visitor: V,
165+
) -> Result<V::Value, Self::Error>
166+
where
167+
V: de::Visitor<'de>,
168+
{
169+
if name == "NodeSeq" {
170+
visitor.visit_borrowed_bytes(unsafe {
171+
core::slice::from_raw_parts(
172+
self as *const _ as *const u8,
173+
core::mem::size_of::<GroupDeserializer<'_>>(),
174+
)
175+
})
176+
} else {
177+
visitor.visit_newtype_struct(self)
178+
}
179+
}
180+
181+
fn deserialize_seq<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
182+
where
183+
V: de::Visitor<'de>,
184+
{
185+
todo!("seq")
186+
}
187+
188+
fn deserialize_tuple<V>(self, _len: usize, _visitor: V) -> Result<V::Value, Self::Error>
189+
where
190+
V: de::Visitor<'de>,
191+
{
192+
todo!("tuple")
193+
}
194+
195+
fn deserialize_tuple_struct<V>(
196+
self,
197+
_name: &'static str,
198+
_len: usize,
199+
_visitor: V,
200+
) -> Result<V::Value, Self::Error>
201+
where
202+
V: de::Visitor<'de>,
203+
{
204+
todo!("tuple_struct")
205+
}
206+
207+
fn deserialize_map<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
208+
where
209+
V: de::Visitor<'de>,
210+
{
211+
todo!("map")
212+
}
213+
214+
fn deserialize_struct<V>(
215+
self,
216+
_name: &'static str,
217+
_fields: &'static [&'static str],
218+
_visitor: V,
219+
) -> Result<V::Value, Self::Error>
220+
where
221+
V: de::Visitor<'de>,
222+
{
223+
todo!("struct")
224+
}
225+
226+
fn deserialize_enum<V>(
227+
self,
228+
_name: &'static str,
229+
_variants: &'static [&'static str],
230+
_visitor: V,
231+
) -> Result<V::Value, Self::Error>
232+
where
233+
V: de::Visitor<'de>,
234+
{
235+
todo!("enum")
236+
}
237+
238+
fn deserialize_identifier<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
239+
where
240+
V: de::Visitor<'de>,
241+
{
242+
todo!("identifer")
243+
}
244+
245+
fn deserialize_ignored_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
246+
where
247+
V: de::Visitor<'de>,
248+
{
249+
todo!("ignored_any")
250+
}
251+
}

src/de_mut/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use serde::de;
66

77
mod cursor;
88
mod data;
9+
mod group;
910
mod node_seq;
1011
mod reg;
1112
mod str_seq;
@@ -19,7 +20,7 @@ pub mod buildin {
1920

2021
use cursor::{BodyCursor, Cursor, GroupCursor, PropCursor};
2122
use data::BorrowedValueDeserializer;
22-
use node_seq::NodeSeq;
23+
use group::GroupDeserializer;
2324
use r#struct::StructDeserializer;
2425
use reg::RegConfig;
2526
use structs::{RefDtb, StructureBlock, BLOCK_LEN};
@@ -146,7 +147,7 @@ impl<'de, 'b> de::MapAccess<'de> for StructAccess<'de, 'b> {
146147
}
147148
Temp::Group(cursor, len_item, len_name) => {
148149
// 键是组名字,构造组反序列化器
149-
seed.deserialize(&mut NodeSeq {
150+
seed.deserialize(&mut GroupDeserializer {
150151
dtb: self.de.dtb,
151152
cursor,
152153
reg: self.de.reg,

0 commit comments

Comments
 (0)