aboutsummaryrefslogtreecommitdiff
path: root/src/deserialization/buffer_deserializer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/deserialization/buffer_deserializer.rs')
-rw-r--r--src/deserialization/buffer_deserializer.rs40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/deserialization/buffer_deserializer.rs b/src/deserialization/buffer_deserializer.rs
index 652e1ff..a4e7b2f 100644
--- a/src/deserialization/buffer_deserializer.rs
+++ b/src/deserialization/buffer_deserializer.rs
@@ -98,7 +98,7 @@ where
};
if let IgnoreEnd::No = ignore_end {
- self.read_end_event(tag_name)?;
+ self.read_end_event(tag_name.as_bytes())?;
}
Ok(deserialized)
@@ -132,7 +132,38 @@ where
)
})?;
- self.read_end_event(tag_name)?;
+ self.read_end_event(tag_name.as_bytes())?;
+
+ deserialized_items.push(deserialized);
+ }
+
+ Ok(deserialized_items)
+ }
+
+ fn de_list<De: Deserialize>(&mut self) -> Result<Vec<De>, DeserializerError>
+ {
+ let mut deserialized_items = Vec::new();
+
+ loop {
+ let start = match read_event!(self) {
+ Event::Start(start) => start,
+ Event::Comment(_) => {
+ continue;
+ }
+ event => {
+ self.leftover_event = Some(event.into_owned());
+ break;
+ }
+ };
+
+ let deserialized = De::deserialize(&start, self).map_err(|err| {
+ DeserializerError::DeserializeFailed(
+ type_name::<De>(),
+ WrappedDeserializeError::new(err),
+ )
+ })?;
+
+ self.read_end_event(start.name().as_ref())?;
deserialized_items.push(deserialized);
}
@@ -193,12 +224,11 @@ impl<Source> BufferDeserializer<Source>
where
Source: BufRead,
{
- fn read_end_event(&mut self, tag_name: &str) -> Result<(), DeserializerError>
+ fn read_end_event(&mut self, tag_name: &[u8]) -> Result<(), DeserializerError>
{
let event = read_event!(self);
- if matches!(&event, Event::End(end) if end.name().as_ref() == tag_name.as_bytes())
- {
+ if matches!(&event, Event::End(end) if end.name().as_ref() == tag_name) {
return Ok(());
}