aboutsummaryrefslogtreecommitdiffstats
path: root/src/reader.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/reader.rs')
-rw-r--r--src/reader.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/reader.rs b/src/reader.rs
index e6bb57c..aa4d467 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -2,7 +2,7 @@ use circular::Buffer;
use futures::{FutureExt, Stream};
use nom::Err;
use std::{
- collections::{hash_set, BTreeMap, HashMap, HashSet},
+ collections::{hash_set, BTreeMap, HashMap, HashSet, VecDeque},
future::Future,
path::Prefix,
pin::{pin, Pin},
@@ -102,12 +102,12 @@ where
pub async fn read_start<'s, T: FromElement>(&'s mut self) -> Result<T> {
let element = self.read_start_tag().await?;
- FromElement::from_element(element)
+ Ok(FromElement::from_element(element)?)
}
pub async fn read<'s, T: FromElement>(&'s mut self) -> Result<T> {
let element = self.read_element().await?;
- FromElement::from_element(element)
+ Ok(FromElement::from_element(element)?)
}
pub async fn read_start_tag<'s>(&'s mut self) -> Result<Element> {
@@ -438,7 +438,7 @@ impl<R> Reader<R> {
name: element_name,
namespace_declaration_overrides: element_namespace_declarations,
attributes,
- content: Vec::new(),
+ content: VecDeque::new(),
});
}
@@ -652,7 +652,7 @@ impl<R> Reader<R> {
namespace_declarations.pop();
} else {
- content = Vec::new();
+ content = VecDeque::new();
}
return Ok(Element {
@@ -666,18 +666,18 @@ impl<R> Reader<R> {
fn content_from_xml(
namespaces: &mut Vec<HashSet<NamespaceDeclaration>>,
xml_content: xml::Content,
- ) -> Result<Vec<Content>> {
- let mut content = Vec::new();
+ ) -> Result<VecDeque<Content>> {
+ let mut content = VecDeque::new();
let mut text = xml_content.char_data.map(|str| String::from(*str));
for (content_item, char_data) in xml_content.content {
match content_item {
xml::ContentItem::Element(element) => {
text.map(|text| {
if !text.is_empty() {
- content.push(Content::Text(text))
+ content.push_back(Content::Text(text))
}
});
- content.push(Content::Element(Self::element_from_xml(
+ content.push_back(Content::Element(Self::element_from_xml(
namespaces, element,
)?));
text = char_data.map(|str| String::from(*str));
@@ -711,7 +711,7 @@ impl<R> Reader<R> {
}
text.map(|text| {
if !text.is_empty() {
- content.push(Content::Text(text))
+ content.push_back(Content::Text(text))
}
});
Ok(content)