Struct IonCAnnotationsFieldWriterContext

Source
pub struct IonCAnnotationsFieldWriterContext<'b, 'c, T: IonCAnnotationsFieldWriter + ?Sized> { /* private fields */ }
Expand description

Context for writing annotations and fields in with proper reference lifetimes.

Specifically, writing annotations and fields with Ion C with ion_writer_write_annotations/ion_writer_add_annotation and ion_writer_write_field is particularly problematic because the lifetime of the ION_STRING passed into that function, must be valid until a corresponding ion_writer_write_* function is called for writing a value.

This context tracks the lifetime of the string slices that a user wants to write as annotations and the field name along with a mutable borrow of the writer handle and ensures that calls to ion_writer_add_annotation/ion_writer_write_field happen before invoking the ion_writer_write_* call for the value in a lifetime correct way.

Note that this context can be thought of as a partial function for writing annotations and/or struct fields, so doing nothing with it is simply a no-op, and performing multiple IonCValueWriter trait method invocations is the same as writing the field before invoking the value writing methods (so duplicate fields would be generated in that case).

Implementations§

Source§

impl<'b, 'c, T: IonCAnnotationsFieldWriter + ?Sized> IonCAnnotationsFieldWriterContext<'b, 'c, T>

Source

pub fn annotations(&mut self, annotations: &'c [&'c str]) -> &mut Self

Sets the annotations for the context.

Source

pub fn field(&mut self, field: &'c str) -> &mut Self

Sets the field name for the context.

Trait Implementations§

Source§

impl<T: IonCAnnotationsFieldWriter + ?Sized> IonCValueWriter for IonCAnnotationsFieldWriterContext<'_, '_, T>

Source§

fn finish_container(&mut self) -> IonCResult<()>

This API is not relevant for this context and will always return an error.

Source§

fn write_null(&mut self, tid: ION_TYPE) -> IonCResult<()>

Writes a null value. Read more
Source§

fn write_bool(&mut self, value: bool) -> IonCResult<()>

Writes a bool value. Read more
Source§

fn write_i64(&mut self, value: i64) -> IonCResult<()>

Writes an int value. Read more
Source§

fn write_bigint(&mut self, value: &BigInt) -> IonCResult<()>

Writes an int value. Read more
Source§

fn write_f64(&mut self, value: f64) -> IonCResult<()>

Writes a float value. Read more
Source§

fn write_bigdecimal(&mut self, value: &BigDecimal) -> IonCResult<()>

Writes a decimal value. Read more
Source§

fn write_datetime(&mut self, value: &IonDateTime) -> IonCResult<()>

Writes a timestamp value. Read more
Source§

fn write_symbol(&mut self, value: &str) -> IonCResult<()>

Writes a symbol value. Read more
Source§

fn write_string(&mut self, value: &str) -> IonCResult<()>

Writes a string value. Read more
Source§

fn write_clob(&mut self, value: &[u8]) -> IonCResult<()>

Writes a clob value. Read more
Source§

fn write_blob(&mut self, value: &[u8]) -> IonCResult<()>

Writes a blob value. Read more
Source§

fn start_container(&mut self, tid: ION_TYPE) -> IonCResult<()>

Starts a container. Read more

Auto Trait Implementations§

§

impl<'b, 'c, T> Freeze for IonCAnnotationsFieldWriterContext<'b, 'c, T>
where T: ?Sized,

§

impl<'b, 'c, T> RefUnwindSafe for IonCAnnotationsFieldWriterContext<'b, 'c, T>
where T: RefUnwindSafe + ?Sized,

§

impl<'b, 'c, T> Send for IonCAnnotationsFieldWriterContext<'b, 'c, T>
where T: Send + ?Sized,

§

impl<'b, 'c, T> Sync for IonCAnnotationsFieldWriterContext<'b, 'c, T>
where T: Sync + ?Sized,

§

impl<'b, 'c, T> Unpin for IonCAnnotationsFieldWriterContext<'b, 'c, T>
where T: ?Sized,

§

impl<'b, 'c, T> !UnwindSafe for IonCAnnotationsFieldWriterContext<'b, 'c, T>

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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.