Struct quick_xml::de::SliceReader
source · pub struct SliceReader<'de> { /* private fields */ }
Available on crate feature
serialize
only.Expand description
XML input source that reads from a slice of bytes and can borrow from it.
You cannot create it, it is created automatically when you call
Deserializer::from_str
.
Implementations§
source§impl<'de> SliceReader<'de>
impl<'de> SliceReader<'de>
sourcepub const fn get_ref(&self) -> &Reader<&'de [u8]>
pub const fn get_ref(&self) -> &Reader<&'de [u8]>
Returns the underlying XML reader.
use serde::Deserialize;
use quick_xml::de::Deserializer;
use quick_xml::Reader;
#[derive(Deserialize)]
struct SomeStruct {
field1: String,
field2: String,
}
// Try to deserialize from broken XML
let mut de = Deserializer::from_str(
"<SomeStruct><field1><field2></SomeStruct>"
// 0 ^= 28 ^= 41
);
let err = SomeStruct::deserialize(&mut de);
assert!(err.is_err());
let reader: &Reader<&[u8]> = de.get_ref().get_ref();
assert_eq!(reader.error_position(), 28);
assert_eq!(reader.buffer_position(), 41);
Trait Implementations§
Auto Trait Implementations§
impl<'de> Freeze for SliceReader<'de>
impl<'de> RefUnwindSafe for SliceReader<'de>
impl<'de> Send for SliceReader<'de>
impl<'de> Sync for SliceReader<'de>
impl<'de> Unpin for SliceReader<'de>
impl<'de> UnwindSafe for SliceReader<'de>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more