pub struct Sequence { /* private fields */ }Expand description
Implementations§
Source§impl Sequence
impl Sequence
pub fn new<E: Into<Element>, I: IntoIterator<Item = E>>(elements: I) -> Sequence
pub fn builder() -> SequenceBuilder
pub fn clone_builder(&self) -> SequenceBuilder
pub fn elements(&self) -> SequenceIterator<'_>
pub fn get(&self, index: usize) -> Option<&Element>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn iter(&self) -> SequenceIterator<'_>
Sourcepub fn encode_as<E: Encoding, C: Into<WriteConfig<E>>>(
&self,
config: C,
) -> IonResult<E::Output>
pub fn encode_as<E: Encoding, C: Into<WriteConfig<E>>>( &self, config: C, ) -> IonResult<E::Output>
use ion_rs::{Element, Sequence};
use ion_rs::v1_0::Binary;
let ion_data = r#"1 2 3 foo bar baz"#;
let sequence_before: Sequence = Element::read_all(ion_data)?;
// Encode the elements in this sequence as a binary Ion stream.
let ion_bytes: Vec<u8> = sequence_before.encode_as(Binary)?;
// Read the sequence back from the binary stream
let sequence_after = Element::read_all(ion_bytes)?;
// Confirm that the value we read back is identical to the one we serialized
assert_eq!(sequence_before, sequence_after);
Sourcepub fn encode_to<E: Encoding, C: Into<WriteConfig<E>>, W: Write>(
&self,
output: W,
config: C,
) -> IonResult<W>
pub fn encode_to<E: Encoding, C: Into<WriteConfig<E>>, W: Write>( &self, output: W, config: C, ) -> IonResult<W>
use ion_rs::{Element, Sequence};
use ion_rs::v1_0::Binary;
let ion_data = r#"1 2 3 foo bar baz"#;
let sequence_before: Sequence = Element::read_all(ion_data)?;
// Encode the elements in this sequence to our buffer as a binary Ion stream. The bytes will
// be written to the provided Vec<u8>, and the Vec<u8> will be returned when encoding is complete.
let ion_bytes: Vec<u8> = sequence_before.encode_to(Vec::new(), Binary)?;
// Read the sequence back from the binary stream
let sequence_after = Element::read_all(ion_bytes)?;
// Confirm that the value we read back is identical to the one we serialized
assert_eq!(sequence_before, sequence_after);
Trait Implementations§
Source§impl FromIterator<Element> for Sequence
impl FromIterator<Element> for Sequence
Source§impl<'a> IntoIterator for &'a Sequence
impl<'a> IntoIterator for &'a Sequence
Source§impl IntoIterator for Sequence
impl IntoIterator for Sequence
impl StructuralPartialEq for Sequence
Auto Trait Implementations§
impl Freeze for Sequence
impl RefUnwindSafe for Sequence
impl Send for Sequence
impl Sync for Sequence
impl Unpin for Sequence
impl UnsafeUnpin for Sequence
impl UnwindSafe for Sequence
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more