mirror of
https://github.com/lennart-k/rustical.git
synced 2026-01-30 11:48:18 +00:00
xml: Some restructuring
This commit is contained in:
31
crates/xml/src/unparsed.rs
Normal file
31
crates/xml/src/unparsed.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use std::io::BufRead;
|
||||
|
||||
use quick_xml::events::BytesStart;
|
||||
|
||||
use crate::{XmlDeserialize, XmlError};
|
||||
|
||||
// TODO: actually implement
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct Unparsed(BytesStart<'static>);
|
||||
|
||||
impl Unparsed {
|
||||
pub fn tag_name(&self) -> String {
|
||||
// TODO: respect namespace?
|
||||
String::from_utf8_lossy(self.0.local_name().as_ref()).to_string()
|
||||
}
|
||||
}
|
||||
|
||||
impl XmlDeserialize for Unparsed {
|
||||
fn deserialize<R: BufRead>(
|
||||
reader: &mut quick_xml::NsReader<R>,
|
||||
start: &BytesStart,
|
||||
empty: bool,
|
||||
) -> Result<Self, XmlError> {
|
||||
// let reader_cloned = NsReader::from_reader(reader.get_ref().to_owned());
|
||||
if !empty {
|
||||
let mut buf = vec![];
|
||||
reader.read_to_end_into(start.name(), &mut buf)?;
|
||||
}
|
||||
Ok(Self(start.to_owned()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user