Skip to main content

ElementReader

Struct ElementReader 

Source
pub struct ElementReader<T, E> { /* private fields */ }
Expand description

Reads a value and hands out the elements of its Streamed sequence without doing IO.

This reads the value from an InputBuffer which is filled by the caller. Reader::read_next of deser::io and adapters for other kinds of IO (for instance async runtimes) use this. T is the type of the value, E the type of the elements of the Streamed sequence which are handed out.

Elements are handed out before more input is needed, so an element is available as soon as its last byte was read (if the stream deserializer supports StreamDeserializer::feed, otherwise once the value is complete).

Implementations§

Source§

impl<T: DeserializeOwned + 'static, E: Send + 'static> ElementReader<T, E>

Source

pub fn new() -> ElementReader<T, E>

Creates a reader for a value.

Source

pub fn is_reading(&self) -> bool

Returns true if a value is being read.

This is false before the first call and after the value was handed out.

Source

pub fn poll<D: StreamDeserializer>( &mut self, buffer: &mut InputBuffer<D>, ) -> Result<ElementStatus<E, T>, Error>

Returns the next element or the value.

Once the value is ready (Part::Done) the reader is done, the next call starts with the next value.

Trait Implementations§

Source§

impl<T: DeserializeOwned + 'static, E: Send + 'static> Default for ElementReader<T, E>

Source§

fn default() -> ElementReader<T, E>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T, E> !RefUnwindSafe for ElementReader<T, E>

§

impl<T, E> !Sync for ElementReader<T, E>

§

impl<T, E> !Unpin for ElementReader<T, E>

§

impl<T, E> !UnwindSafe for ElementReader<T, E>

§

impl<T, E> Freeze for ElementReader<T, E>
where Option<OwnedDriver<'static, T>>: Freeze, Option<T>: Freeze, PhantomData<fn() -> E>: Freeze,

§

impl<T, E> Send for ElementReader<T, E>
where Option<OwnedDriver<'static, T>>: Send, Option<T>: Send, PhantomData<fn() -> E>: Send,

§

impl<T, E> UnsafeUnpin for ElementReader<T, E>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.