Skip to main content

ValueWriter

Struct ValueWriter 

Source
pub struct ValueWriter<'c, 'o> { /* private fields */ }
Expand description

Writes values at their types into a buffer: the runtime’s own values (write_value), and a Rust value its Shaped mapping writes part by part, with no runtime value between.

Implementations§

Source§

impl<'c> ValueWriter<'c, '_>

Source

pub fn catalog(&self) -> &'c Catalog

The catalog the types written at are in.

Source

pub fn refuse(&self, ty: &Type) -> EncodeError

The refusal of a value written at ty, a type the Rust type does not map to.

Source

pub fn unit(&mut self, ty: &Type) -> Result<(), EncodeError>

Writes Unit at ty.

§Errors

When ty is not Unit; so for every writer below and its type.

Source

pub fn bool(&mut self, ty: &Type, flag: bool) -> Result<(), EncodeError>

Writes a Bool.

§Errors

As ValueWriter::unit.

Source

pub fn int(&mut self, ty: &Type, number: &Int) -> Result<(), EncodeError>

Writes an Int.

§Errors

As ValueWriter::unit.

Source

pub fn decimal( &mut self, ty: &Type, number: &Decimal, ) -> Result<(), EncodeError>

Writes a Decimal.

§Errors

As ValueWriter::unit.

Source

pub fn duration( &mut self, ty: &Type, span: &Duration, ) -> Result<(), EncodeError>

Writes a Duration.

§Errors

As ValueWriter::unit.

Source

pub fn instant(&mut self, ty: &Type, at: &Instant) -> Result<(), EncodeError>

Writes an Instant.

§Errors

As ValueWriter::unit.

Source

pub fn text(&mut self, ty: &Type, text: &str) -> Result<(), EncodeError>

Writes a Text.

§Errors

As ValueWriter::unit.

Source

pub fn bytes(&mut self, ty: &Type, bytes: &[u8]) -> Result<(), EncodeError>

Writes Bytes.

§Errors

As ValueWriter::unit.

Source

pub fn host(&mut self, ty: &Type, token: &str) -> Result<(), EncodeError>

Writes a host type’s value, its token.

§Errors

As ValueWriter::unit.

Source

pub fn list<'v, T: Shaped>( &mut self, ty: &Type, items: impl ExactSizeIterator<Item = &'v T>, ) -> Result<(), EncodeError>

Writes a list of items.

§Errors

When ty is no list, or an item is not of its element type.

Source

pub fn set<'v, T: Shaped>( &mut self, ty: &Type, items: impl ExactSizeIterator<Item = &'v T>, ) -> Result<(), EncodeError>

Writes a set of items, in Flow’s order of them.

§Errors

When ty is no set, an item is not of its element type, or two items are one value.

Source

pub fn dict<'v, K: Shaped, V: Shaped>( &mut self, ty: &Type, entries: impl ExactSizeIterator<Item = (&'v K, &'v V)>, ) -> Result<(), EncodeError>

Writes a dictionary of entries, in Flow’s order of their keys.

§Errors

When ty is no dictionary, a key or a value is not of its type, or two keys are one value.

Source

pub fn tuple( &mut self, ty: &Type, parts: &[&dyn Part], ) -> Result<(), EncodeError>

Writes a tuple of parts.

§Errors

When ty is no tuple of as many parts, or a part is not of its type.

Source

pub fn record( &mut self, ty: &Type, fields: &[&dyn Part], ) -> Result<(), EncodeError>

Writes a record of fields, in declaration order.

§Errors

When ty is no record of as many fields, or a field is not of its type.

Source

pub fn variant( &mut self, ty: &Type, index: usize, payload: &[&dyn Part], ) -> Result<(), EncodeError>

Writes the value of the constructor at index of the enum ty, Option and Result included, with payload.

§Errors

When ty is no enum with that constructor taking as many parts, or a part is not of its type.

Source

pub fn newtype(&mut self, ty: &Type, base: &dyn Part) -> Result<(), EncodeError>

Writes a value of the newtype ty, its base’s base, held to the form ty has, if any.

§Errors

When ty is no newtype, base is not of its base, or is out of its form.

Source

pub fn encoded(&mut self, ty: &Type, bytes: &[u8]) -> Result<(), EncodeError>

Writes bytes, which hold one value of ty.

§Errors

When they do not: they are checked as a decoder checks them.

Trait Implementations§

Source§

impl<'c, 'o> Debug for ValueWriter<'c, 'o>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'c, 'o> !UnwindSafe for ValueWriter<'c, 'o>

§

impl<'c, 'o> Forget for ValueWriter<'c, 'o>

§

impl<'c, 'o> Freeze for ValueWriter<'c, 'o>
where &'c Catalog: Freeze, &'o mut Vec<u8>: Freeze, *const u8 is !null: Freeze, PhantomData<Step>: Freeze,

§

impl<'c, 'o> Move for ValueWriter<'c, 'o>

§

impl<'c, 'o> RefUnwindSafe for ValueWriter<'c, 'o>

§

impl<'c, 'o> Send for ValueWriter<'c, 'o>
where &'c Catalog: Send, RawVecInner: Send,

§

impl<'c, 'o> Sync for ValueWriter<'c, 'o>
where RawVecInner: Sync, Arc<RecordShape>: Sync, BoxRaw<Type>: Sync, Arc<EnumShape>: Sync, Mutex<HashMap<(Type, Settings), Option<String>>>: Sync, RawTable<(Box<str>, usize)>: Sync, BoxRaw<[usize]>: Sync, BoxRaw<[Option<OptionCtor>]>: Sync, BoxRaw<[Option<JsonValueCtor>]>: Sync,

§

impl<'c, 'o> Unpin for ValueWriter<'c, 'o>
where &'c Catalog: Unpin, &'o mut Vec<u8>: Unpin, *const u8 is !null: Unpin,

§

impl<'c, 'o> UnsafeUnpin for ValueWriter<'c, 'o>

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

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.