pub struct IonParser<T: Read> { /* private fields */ }
Expand description

In order to use it call the new method and then the “consume_all” method.

§Example


use ion_binary_rs::IonParser;

// This is the response from Amazon's QLDB introduction example using Rusoto
let ion_test = b"\xe0\x01\0\xea\xee\xa6\x81\x83\xde\xa2\x87\xbe\x9f\x83VIN\x84Type\x84Year\x84Make\x85Model\x85Color\xde\xb9\x8a\x8e\x911C4RJFAG0FC625797\x8b\x85Sedan\x8c\"\x07\xe3\x8d\x88Mercedes\x8e\x87CLK 350\x8f\x85White";

let mut parser = IonParser::new(&ion_test[..]);

println!("Decoded Ion: {:?}", parser.consume_all().unwrap())
// Decoded Ion: [Struct({"Color": String("White"), "Year": Integer(2019), "VIN": String("1C4RJFAG0FC625797"), "Make": String("Mercedes"), "Model": String("CLK 350"), "Type": String("Sedan")})]

Implementations§

source§

impl<T: Read> IonParser<T>

source

pub fn new(reader: T) -> IonParser<T>

Creates a new parser. It accepts anything that implements the trait Read Trait

source

pub fn with_shared_table( &mut self, name: String, version: u32, symbols: &[String] ) -> Result<(), SymbolContextError>

Allows to set up shared tables in order to define symbols that are not in the binary blob. This is useful when decoding binaries that depend of huge tables that are expected to exist in the client and not to be sent in the ion binary.

source

pub fn consume_all(&mut self) -> Result<Vec<IonValue>, IonParserError>

Consumes all the IonValues in the binary blob and returns an array with them.

source

pub fn consume_value(&mut self) -> Result<(IonValue, usize), IonParserError>

Consumes one IonValue and stops. This function will automatically process NOP Padding, Shared Tables and Local Tables, automatically continuing in case that any of them are found.

Trait Implementations§

source§

impl<T: Debug + Read> Debug for IonParser<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for IonParser<T>
where T: RefUnwindSafe,

§

impl<T> Send for IonParser<T>
where T: Send,

§

impl<T> Sync for IonParser<T>
where T: Sync,

§

impl<T> Unpin for IonParser<T>
where T: Unpin,

§

impl<T> UnwindSafe for IonParser<T>
where T: 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.