Skip to main content

CborSerializer

Struct CborSerializer 

Source
pub struct CborSerializer { /* private fields */ }
Expand description

CBOR serializer that implements the [ShapeSerializer] trait.

Wraps the existing optimized Encoder which uses minicbor with infallible writes to Vec<u8>.

Implementations§

Source§

impl CborSerializer

Source

pub fn with_struct_prefix(self, prefix: StructPrefix) -> Self

Installs a callback that writes members into each currently open structure map before its modeled members. The callback receives the value’s schema, preserving the supplied member schema for field naming. Errors stop serialization immediately. By default, no callback is installed.

Trait Implementations§

Source§

impl FinishSerializer for CborSerializer

Source§

fn finish(self) -> Vec<u8> ⓘ

Consumes the serializer and returns the serialized bytes.
Source§

impl ShapeSerializer for CborSerializer

Source§

fn write_struct( &mut self, schema: &Schema<'_>, value: &dyn SerializableStruct, ) -> Result<(), SerdeError>

Writes a structure to the serializer. Read more
Source§

fn write_list( &mut self, schema: &Schema<'_>, write_elements: &dyn Fn(&mut dyn ShapeSerializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Writes a list to the serializer. Read more
Source§

fn write_map( &mut self, schema: &Schema<'_>, write_entries: &dyn Fn(&mut dyn ShapeSerializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Writes a map to the serializer. Read more
Source§

fn write_list_with_length( &mut self, schema: &Schema<'_>, length: usize, write_elements: &dyn Fn(&mut dyn ShapeSerializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Writes a list with a known number of elements, including sparse nulls. Read more
Source§

fn write_map_with_length( &mut self, schema: &Schema<'_>, length: usize, write_entries: &dyn Fn(&mut dyn ShapeSerializer) -> Result<(), SerdeError>, ) -> Result<(), SerdeError>

Writes a map with a known number of entries, including sparse null values. Read more
Source§

fn write_boolean( &mut self, schema: &Schema<'_>, value: bool, ) -> Result<(), SerdeError>

Writes a boolean value.
Source§

fn write_byte( &mut self, schema: &Schema<'_>, value: i8, ) -> Result<(), SerdeError>

Writes a byte (i8) value.
Source§

fn write_short( &mut self, schema: &Schema<'_>, value: i16, ) -> Result<(), SerdeError>

Writes a short (i16) value.
Source§

fn write_integer( &mut self, schema: &Schema<'_>, value: i32, ) -> Result<(), SerdeError>

Writes an integer (i32) value.
Source§

fn write_integer_list( &mut self, schema: &Schema<'_>, values: &[i32], ) -> Result<(), SerdeError>

Writes a list of integers.
Source§

fn write_long( &mut self, schema: &Schema<'_>, value: i64, ) -> Result<(), SerdeError>

Writes a long (i64) value.
Source§

fn write_float( &mut self, schema: &Schema<'_>, value: f32, ) -> Result<(), SerdeError>

Writes a float (f32) value.
Source§

fn write_double( &mut self, schema: &Schema<'_>, value: f64, ) -> Result<(), SerdeError>

Writes a double (f64) value.
Source§

fn write_big_integer( &mut self, schema: &Schema<'_>, value: &BigInteger, ) -> Result<(), SerdeError>

Writes a big integer value.
Source§

fn write_big_decimal( &mut self, schema: &Schema<'_>, value: &BigDecimal, ) -> Result<(), SerdeError>

Writes a big decimal value.
Source§

fn write_string( &mut self, schema: &Schema<'_>, value: &str, ) -> Result<(), SerdeError>

Writes a string value.
Source§

fn write_blob( &mut self, schema: &Schema<'_>, value: Blob, ) -> Result<(), SerdeError>

Writes a blob (byte array) value. Read more
Source§

fn write_timestamp( &mut self, schema: &Schema<'_>, value: &DateTime, ) -> Result<(), SerdeError>

Writes a timestamp value.
Source§

fn write_document( &mut self, _schema: &Schema<'_>, _value: &Document, ) -> Result<(), SerdeError>

Writes a document value. Read more
Source§

fn write_null(&mut self, schema: &Schema<'_>) -> Result<(), SerdeError>

Writes a null value (for sparse collections).
§

fn write_string_list( &mut self, schema: &Schema<'_>, values: &[String], ) -> Result<(), SerdeError>

Writes a list of strings.
§

fn write_blob_list( &mut self, schema: &Schema<'_>, values: &[Blob], ) -> Result<(), SerdeError>

Writes a list of blobs.
§

fn write_long_list( &mut self, schema: &Schema<'_>, values: &[i64], ) -> Result<(), SerdeError>

Writes a list of longs.
§

fn write_string_string_map( &mut self, schema: &Schema<'_>, values: &HashMap<String, String>, ) -> Result<(), SerdeError>

Writes a map with string keys and string values.

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
§

impl<S> PayloadSerializer for S
where S: ShapeSerializer + FinishSerializer,

§

fn finish_boxed(self: Box<S>) -> Vec<u8> ⓘ

Consumes this boxed serializer and returns the serialized bytes.
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,