pub struct Serializer<'a, W> { /* private fields */ }
Expand description

Defines the BSATN serialization data format.

Implementations§

source§

impl<'a, W> Serializer<'a, W>

source

pub fn new(writer: &'a mut W) -> Self

Returns a serializer using the given writer.

Trait Implementations§

source§

impl<W: BufWriter> SerializeArray for Serializer<'_, W>

§

type Ok = ()

Must match the Ok type of any Serializer that uses this type.
§

type Error = BsatnError

Must match the Error type of any Serializer that uses this type.
source§

fn serialize_element<T: Serialize + ?Sized>( &mut self, elem: &T ) -> Result<(), Self::Error>

Serialize an array element.
source§

fn end(self) -> Result<Self::Ok, Self::Error>

Consumes and finalizes the array serializer returning the Self::Ok data.
source§

impl<W: BufWriter> SerializeMap for Serializer<'_, W>

§

type Ok = ()

Must match the Ok type of any Serializer that uses this type.
§

type Error = BsatnError

Must match the Error type of any Serializer that uses this type.
source§

fn serialize_entry<K: Serialize + ?Sized, V: Serialize + ?Sized>( &mut self, key: &K, value: &V ) -> Result<(), Self::Error>

Serialize a map entry given by its key and value.
source§

fn end(self) -> Result<Self::Ok, Self::Error>

Consumes and finalizes the map serializer returning the Self::Ok data.
source§

impl<W: BufWriter> SerializeSeqProduct for Serializer<'_, W>

§

type Ok = ()

Must match the Ok type of any Serializer that uses this type.
§

type Error = BsatnError

Must match the Error type of any Serializer that uses this type.
source§

fn serialize_element<T: Serialize + ?Sized>( &mut self, elem: &T ) -> Result<(), Self::Error>

Serialize an unnamed product element.
source§

fn end(self) -> Result<Self::Ok, Self::Error>

Consumes and finalizes the product serializer returning the Self::Ok data.
source§

impl<W: BufWriter> Serializer for Serializer<'_, W>

§

type Ok = ()

The output type produced by this Serializer during successful serialization. Read more
§

type Error = BsatnError

The error type when some error occurs during serialization.
§

type SerializeArray = Serializer<'_, W>

Type returned from serialize_array for serializing the contents of the array.
§

type SerializeMap = Serializer<'_, W>

Type returned from serialize_map for serializing the contents of the map.
§

type SerializeSeqProduct = Serializer<'_, W>

Type returned from serialize_seq_product for serializing the contents of the unnamed product.
§

type SerializeNamedProduct = ForwardNamedToSeqProduct<Serializer<'_, W>>

Type returned from serialize_named_product for serializing the contents of the named product.
source§

fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>

Serialize a bool value.
source§

fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>

Serialize a u8 value.
source§

fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>

Serialize a u16 value.
source§

fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>

Serialize a u32 value.
source§

fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>

Serialize a u64 value.
source§

fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>

Serialize a u128 value.
source§

fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>

Serialize an i8 value.
source§

fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>

Serialize an i16 value.
source§

fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>

Serialize an i32 value.
source§

fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>

Serialize an i64 value.
source§

fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>

Serialize an i128 value.
source§

fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>

Serialize an f32 value.
source§

fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>

Serialize an f64 value.
source§

fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>

Serialize a &str string slice.
source§

fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>

Serialize a &[u8] byte slice.
source§

fn serialize_array( self, len: usize ) -> Result<Self::SerializeArray, Self::Error>

Begin to serialize a variably sized array. This call must be followed by zero or more calls to SerializeArray::serialize_element, then a call to SerializeArray::end. Read more
source§

fn serialize_map(self, len: usize) -> Result<Self::SerializeMap, Self::Error>

Begin to serialize a variably sized map. This call must be followed by zero or more calls to [SerializeMap::serialize_element], then a call to SerializeMap::end. Read more
source§

fn serialize_seq_product( self, _len: usize ) -> Result<Self::SerializeSeqProduct, Self::Error>

Begin to serialize a product with unnamed fields. This call must be followed by zero or more calls to SerializeSeqProduct::serialize_element, then a call to SerializeSeqProduct::end. Read more
source§

fn serialize_named_product( self, len: usize ) -> Result<Self::SerializeNamedProduct, Self::Error>

Begin to serialize a product with named fields. This call must be followed by zero or more calls to SerializeNamedProduct::serialize_element, then a call to SerializeNamedProduct::end. Read more
source§

fn serialize_variant<T: Serialize + ?Sized>( self, tag: u8, _name: Option<&str>, value: &T ) -> Result<Self::Ok, Self::Error>

Serialize a sum value provided the chosen tag, name, and value.
source§

unsafe fn serialize_bsatn( self, ty: &AlgebraicType, bsatn: &[u8] ) -> Result<Self::Ok, Self::Error>

Serialize the given bsatn encoded data of type ty. Read more
source§

unsafe fn serialize_bsatn_in_chunks<'a, I: Clone + Iterator<Item = &'a [u8]>>( self, ty: &AlgebraicType, total_bsatn_len: usize, bsatn: I ) -> Result<Self::Ok, Self::Error>

Serialize the given bsatn encoded data of type ty. Read more
source§

unsafe fn serialize_str_in_chunks<'a, I: Clone + Iterator<Item = &'a [u8]>>( self, total_len: usize, string: I ) -> Result<Self::Ok, Self::Error>

Serialize the given string. Read more

Auto Trait Implementations§

§

impl<'a, W> RefUnwindSafe for Serializer<'a, W>
where W: RefUnwindSafe,

§

impl<'a, W> Send for Serializer<'a, W>
where W: Send,

§

impl<'a, W> Sync for Serializer<'a, W>
where W: Sync,

§

impl<'a, W> Unpin for Serializer<'a, W>

§

impl<'a, W> !UnwindSafe for Serializer<'a, W>

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> Instrument for T

source§

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

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

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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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