[−][src]Struct ion_binary_rs::IonEncoder
Allows to binary encode one or multiple IonValue.
Given how Ion format works there are two methods in order to use this utility.
add
allows to add IonValue to the buffer to later encoding.encode
takes all biffered values and encodes them, generating the symbol's table and the ion header. It returns a Vec.
use ion_binary_rs::{IonEncoder, IonParser, IonValue}; use std::collections::HashMap; let mut ion_struct = HashMap::new(); ion_struct.insert("Model".to_string(), IonValue::String("CLK 350".to_string())); ion_struct.insert("Type".to_string(), IonValue::String("Sedan".to_string())); ion_struct.insert("Color".to_string(), IonValue::String("White".to_string())); ion_struct.insert( "VIN".to_string(), IonValue::String("1C4RJFAG0FC625797".to_string()), ); ion_struct.insert("Make".to_string(), IonValue::String("Mercedes".to_string())); ion_struct.insert("Year".to_string(), IonValue::Integer(2019)); let ion_value = IonValue::Struct(ion_struct); let mut encoder = IonEncoder::new(); encoder.add(ion_value.clone()); let bytes = encoder.encode(); let resulting_ion_value = IonParser::new(&bytes[..]).consume_value().unwrap().0; assert_eq!(ion_value, resulting_ion_value);
Implementations
impl IonEncoder
[src]
pub fn new() -> IonEncoder
[src]
pub fn add(&mut self, value: IonValue)
[src]
pub fn encode(&mut self) -> Vec<u8>
[src]
Trait Implementations
impl Debug for IonEncoder
[src]
impl Default for IonEncoder
[src]
Auto Trait Implementations
impl RefUnwindSafe for IonEncoder
[src]
impl Send for IonEncoder
[src]
impl Sync for IonEncoder
[src]
impl Unpin for IonEncoder
[src]
impl UnwindSafe for IonEncoder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,