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>
impl<T: DeserializeOwned + 'static, E: Send + 'static> ElementReader<T, E>
Sourcepub fn new() -> ElementReader<T, E>
pub fn new() -> ElementReader<T, E>
Creates a reader for a value.
Sourcepub fn is_reading(&self) -> bool
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.
Sourcepub fn poll<D: StreamDeserializer>(
&mut self,
buffer: &mut InputBuffer<D>,
) -> Result<ElementStatus<E, T>, Error>
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.