Trait ion_rs::element::reader::ElementReader
source · 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§
type ElementIterator<'a>: Iterator<Item = IonResult<Element>> where Self: 'a
Required Methods§
sourcefn read_next_element(&mut self) -> IonResult<Option<Element>>
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)
.
sourcefn elements(&mut self) -> Self::ElementIterator<'_>
fn elements(&mut self) -> Self::ElementIterator<'_>
Returns an iterator over the Elements in the data stream.
Provided Methods§
sourcefn read_one_element(&mut self) -> IonResult<Element>
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)
.