pub struct GenericAsyncReader<T, P: Parse = Parser> { /* private fields */ }
tokio
only.Expand description
Generic tokio-compatible asynchronous driver for restricted XML parsers.
This type is best used through its aliases:
AsyncReader
which usesParser
and provides full XML namespacing supportAsyncRawReader
which usesRawParser
and comes with limitations around validity checking and does not support XML namespaces.
The aliases have more extensive usage documentation as well as examples.
Implementations§
Source§impl<T, P: Parse + Default> GenericAsyncReader<T, P>
impl<T, P: Parse + Default> GenericAsyncReader<T, P>
Source§impl<T, P: Parse + WithOptions> GenericAsyncReader<T, P>
impl<T, P: Parse + WithOptions> GenericAsyncReader<T, P>
Sourcepub fn with_options(inner: T, options: Options) -> Self
pub fn with_options(inner: T, options: Options) -> Self
Create a reader while configuring the parser with the given options.
Source§impl<T, P: Parse> GenericAsyncReader<T, P>
impl<T, P: Parse> GenericAsyncReader<T, P>
Sourcepub fn into_inner(self) -> (T, P)
pub fn into_inner(self) -> (T, P)
Decompose the AsyncReader into its parts
Sourcepub fn inner_pinned(self: Pin<&mut Self>) -> Pin<&mut T>
pub fn inner_pinned(self: Pin<&mut Self>) -> Pin<&mut T>
Access the inner AsyncBufRead, mutably and pinned.
Sourcepub fn parser_mut(&mut self) -> &mut P
pub fn parser_mut(&mut self) -> &mut P
Access the parser, mutably
Sourcepub fn parser_pinned(self: Pin<&mut Self>) -> &mut P
pub fn parser_pinned(self: Pin<&mut Self>) -> &mut P
Access the inner parser, mutably and while pinned.
Source§impl<T: AsyncBufRead, P: Parse> GenericAsyncReader<T, P>
impl<T: AsyncBufRead, P: Parse> GenericAsyncReader<T, P>
Sourcepub fn poll_read(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<P::Output>>>
pub fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Result<Option<P::Output>>>
Attempts to parse a single event from the source.
If the EOF has been reached with a valid document, None
is returned.
I/O errors may be retried, all other errors are fatal (and will be returned again by the parser on the next invocation without reading further data from the source).
In most cases, it is advisable to use read
instead.
Source§impl<T: AsyncBufRead + Unpin, P: Parse> GenericAsyncReader<T, P>
impl<T: AsyncBufRead + Unpin, P: Parse> GenericAsyncReader<T, P>
Sourcepub fn read(&mut self) -> ReadEvent<'_, T, P>
pub fn read(&mut self) -> ReadEvent<'_, T, P>
Read a single event from the parser.
§End-of-file handling
If poll_fill_buf()
returns an empty buffer, it is treated as the end
of file. At end of file, either the return value None
is produced or
an error.
§I/O error handling
Any I/O error is passed back to the caller. This allows any I/O error to be retried (though the success of that will obviously depend on the backing reader).
§Parser error handling
Errors returned by the parser are fatal and are returned as
InvalidData
io::Error
error values.
Equivalent to:
async fn read(&mut self) -> Result<Option<Event>>;
Sourcepub fn read_all<F>(&mut self, cb: F) -> ReadAll<'_, T, P, F>
pub fn read_all<F>(&mut self, cb: F) -> ReadAll<'_, T, P, F>
Read all events which can be produced from the data source (at this point in time).
The given cb
is invoked for each event.
§End-of-file handling
If poll_fill_buf()
returns an empty buffer, it is treated as the end
of file. At end of file the function returns (either successfully or
with an error).
§I/O error handling
Any I/O error is passed back to the caller. This allows any I/O error to be retried (though the success of that will obviously depend on the backing reader).
§Parser error handling
Errors returned by the parser are fatal and are returned as
InvalidData
io::Error
error values.
Equivalent to:
async fn read_all<F>(&mut self, mut cb: F) -> Result<()>
where F: FnMut(Event) -> () + Send
Trait Implementations§
Source§impl<T: AsyncBufRead, P: Parse> Stream for GenericAsyncReader<T, P>
Available on crate feature stream
only.
impl<T: AsyncBufRead, P: Parse> Stream for GenericAsyncReader<T, P>
stream
only.