GenericAsyncReader

Struct GenericAsyncReader 

Source
pub struct GenericAsyncReader<T, P: Parse = Parser> { /* private fields */ }
Available on crate feature tokio only.
Expand description

Generic tokio-compatible asynchronous driver for restricted XML parsers.

This type is best used through its aliases:

The aliases have more extensive usage documentation as well as examples.

Implementations§

Source§

impl<T, P: Parse + Default> GenericAsyncReader<T, P>

Source

pub fn new(inner: T) -> Self

Create a reader using a parser with default options, wrapping the given reader.

Source§

impl<T, P: Parse + WithOptions> GenericAsyncReader<T, P>

Source

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>

Source

pub fn wrap(inner: T, parser: P) -> Self

Create a reader from its inner parts.

Source

pub fn into_inner(self) -> (T, P)

Decompose the AsyncReader into its parts

Source

pub fn inner(&self) -> &T

Access the inner AsyncBufRead

Source

pub fn inner_mut(&mut self) -> &mut T

Access the inner AsyncBufRead, mutably

Source

pub fn inner_pinned(self: Pin<&mut Self>) -> Pin<&mut T>

Access the inner AsyncBufRead, mutably and pinned.

Source

pub fn parser(&self) -> &P

Access the parser

Source

pub fn parser_mut(&mut self) -> &mut P

Access the parser, mutably

Source

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>

Source

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>

Source

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>>;
Source

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.
Source§

type Item = Result<<P as Parse>::Output, Error>

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Source§

impl<'__pin, T, P: Parse> Unpin for GenericAsyncReader<T, P>
where __Origin<'__pin, T, P>: Unpin,

Auto Trait Implementations§

§

impl<T, P> Freeze for GenericAsyncReader<T, P>
where T: Freeze, P: Freeze,

§

impl<T, P> RefUnwindSafe for GenericAsyncReader<T, P>

§

impl<T, P> Send for GenericAsyncReader<T, P>
where T: Send, P: Send,

§

impl<T, P> Sync for GenericAsyncReader<T, P>
where T: Sync, P: Sync,

§

impl<T, P> UnwindSafe for GenericAsyncReader<T, P>
where T: UnwindSafe, P: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<S, T, E> TryStream for S
where S: Stream<Item = Result<T, E>> + ?Sized,

Source§

type Ok = T

The type of successful values yielded by this future
Source§

type Error = E

The type of failures yielded by this future
Source§

fn try_poll_next( self: Pin<&mut S>, cx: &mut Context<'_>, ) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

Poll this TryStream as if it were a Stream. Read more