trait XmlSource<'r, B> {
// Required methods
fn remove_utf8_bom(&mut self) -> Result<()>;
fn read_text(&mut self, buf: B, position: &mut u64) -> ReadTextResult<'r, B>;
fn read_with<P>(
&mut self,
parser: P,
buf: B,
position: &mut u64,
) -> Result<&'r [u8], Error>
where P: Parser;
fn read_bang_element(
&mut self,
buf: B,
position: &mut u64,
) -> Result<(BangType, &'r [u8]), Error>;
fn skip_whitespace(&mut self, position: &mut u64) -> Result<()>;
fn peek_one(&mut self) -> Result<Option<u8>>;
}
Expand description
Represents an input for a reader that can return borrowed data.
There are two implementors of this trait: generic one that read data from
Self
, copies some part of it into a provided buffer of type B
and then
returns data that borrow from that buffer.
The other implementor is for &[u8]
and instead of copying data returns
borrowed data from Self
instead. This implementation allows zero-copy
deserialization.
§Parameters
'r
: lifetime of a buffer from which events will borrowB
: a type of a buffer that can be used to store data read fromSelf
and from which events can borrow
Required Methods§
Sourcefn remove_utf8_bom(&mut self) -> Result<()>
fn remove_utf8_bom(&mut self) -> Result<()>
Removes UTF-8 BOM if it is present
Sourcefn read_text(&mut self, buf: B, position: &mut u64) -> ReadTextResult<'r, B>
fn read_text(&mut self, buf: B, position: &mut u64) -> ReadTextResult<'r, B>
Sourcefn read_with<P>(
&mut self,
parser: P,
buf: B,
position: &mut u64,
) -> Result<&'r [u8], Error>where
P: Parser,
fn read_with<P>(
&mut self,
parser: P,
buf: B,
position: &mut u64,
) -> Result<&'r [u8], Error>where
P: Parser,
Read input until processing instruction is finished.
This method expect that start sequence of a parser already was read.
Returns a slice of data read up to the end of the thing being parsed. The end of thing and the returned content is determined by the used parser.
If input (Self
) is exhausted and no bytes was read, or if the specified
parser could not find the ending sequence of the thing, returns SyntaxError
.
§Parameters
buf
: Buffer that could be filled from an input (Self
) and from which events could borrow their dataposition
: Will be increased by amount of bytes consumed
A P
type parameter is used to preserve state between calls to the underlying
reader which provides bytes fed into the parser.
Sourcefn read_bang_element(
&mut self,
buf: B,
position: &mut u64,
) -> Result<(BangType, &'r [u8]), Error>
fn read_bang_element( &mut self, buf: B, position: &mut u64, ) -> Result<(BangType, &'r [u8]), Error>
Read input until comment or CDATA is finished.
This method expect that <
already was read.
Returns a slice of data read up to end of comment or CDATA (>
),
which does not include into result.
If input (Self
) is exhausted and nothing was read, returns None
.
§Parameters
buf
: Buffer that could be filled from an input (Self
) and from which events could borrow their dataposition
: Will be increased by amount of bytes consumed
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<'a> XmlSource<'a, ()> for &'a [u8]
Implementation of XmlSource
for &[u8]
reader using a Self
as buffer
that will be borrowed by events. This implementation provides a zero-copy deserialization
impl<'a> XmlSource<'a, ()> for &'a [u8]
Implementation of XmlSource
for &[u8]
reader using a Self
as buffer
that will be borrowed by events. This implementation provides a zero-copy deserialization