pub trait ElementReader {
    type ElementIterator<'a>: Iterator<Item = IonResult<Element>>
       where Self: 'a;

    // Required methods
    fn read_next_element(&mut self) -> IonResult<Option<Element>>;
    fn elements(&mut self) -> Self::ElementIterator<'_>;

    // Provided methods
    fn read_one_element(&mut self) -> IonResult<Element> { ... }
    fn read_all_elements(&mut self) -> IonResult<Vec<Element>> { ... }
}
Expand description

Reads Ion data into Element instances.

This trait is automatically implemented by all Ion reader implementations that operate at the highest layer of abstraction, sometimes called the ‘user’ layer.

Required Associated Types§

source

type ElementIterator<'a>: Iterator<Item = IonResult<Element>> where Self: 'a

Required Methods§

source

fn read_next_element(&mut self) -> IonResult<Option<Element>>

Recursively materializes the next Ion value, returning it as an Ok(Element). If there is no more data left to be read, returns Ok(None). If an error occurs while the data is being read, returns Err(IonError).

source

fn elements(&mut self) -> Self::ElementIterator<'_>

Returns an iterator over the Elements in the data stream.

Provided Methods§

source

fn read_one_element(&mut self) -> IonResult<Element>

Like Self::read_next_element, this method reads the next Ion value in the input stream, returning it as an Ok(Element). However, it also requires that the stream contain exactly one value.

If the stream’s data is valid and it contains one value, returns Ok(Element). If the stream’s data is invalid or the stream does not contain exactly one value, returns Err(IonError).

source

fn read_all_elements(&mut self) -> IonResult<Vec<Element>>

Reads all of the values in the input stream, materializing each into an Element and returning the complete sequence as a Vec<Element>.

If an error occurs while reading, returns Err(IonError).

Implementors§

source§

impl<R> ElementReader for Rwhere R: IonReader<Item = StreamItem, Symbol = Symbol> + ?Sized,

§

type ElementIterator<'a> where R: 'a = ElementIterator<'a, R>