Serializer

Struct Serializer 

Source
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) -> Serializer<'a, W>

Returns a serializer using the given writer.

Trait Implementations§

Source§

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

Source§

type Ok = ()

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

type Error = BsatnError

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

fn serialize_element<T>( &mut self, elem: &T, ) -> Result<(), <Serializer<'_, W> as SerializeArray>::Error>
where T: Serialize + ?Sized,

Serialize an array element.
Source§

fn end( self, ) -> Result<<Serializer<'_, W> as SerializeArray>::Ok, <Serializer<'_, W> as SerializeArray>::Error>

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

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

Source§

type Ok = ()

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

type Error = BsatnError

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

fn serialize_element<T>( &mut self, elem: &T, ) -> Result<(), <Serializer<'_, W> as SerializeSeqProduct>::Error>
where T: Serialize + ?Sized,

Serialize an unnamed product element.
Source§

fn end( self, ) -> Result<<Serializer<'_, W> as SerializeSeqProduct>::Ok, <Serializer<'_, W> as SerializeSeqProduct>::Error>

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

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

Source§

type Ok = ()

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

type Error = BsatnError

The error type when some error occurs during serialization.
Source§

type SerializeArray = Serializer<'_, W>

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

type SerializeSeqProduct = Serializer<'_, W>

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

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<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a bool value.
Source§

fn serialize_u8( self, v: u8, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u8 value.
Source§

fn serialize_u16( self, v: u16, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u16 value.
Source§

fn serialize_u32( self, v: u32, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u32 value.
Source§

fn serialize_u64( self, v: u64, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u64 value.
Source§

fn serialize_u128( self, v: u128, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u128 value.
Source§

fn serialize_u256( self, v: U256, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a u256 value.
Source§

fn serialize_i8( self, v: i8, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i8 value.
Source§

fn serialize_i16( self, v: i16, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i16 value.
Source§

fn serialize_i32( self, v: i32, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i32 value.
Source§

fn serialize_i64( self, v: i64, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i64 value.
Source§

fn serialize_i128( self, v: i128, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i128 value.
Source§

fn serialize_i256( self, v: I256, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an i256 value.
Source§

fn serialize_f32( self, v: f32, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an f32 value.
Source§

fn serialize_f64( self, v: f64, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize an f64 value.
Source§

fn serialize_str( self, v: &str, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a &str string slice.
Source§

fn serialize_bytes( self, v: &[u8], ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>

Serialize a &[u8] byte slice.
Source§

fn serialize_array( self, len: usize, ) -> Result<<Serializer<'_, W> as Serializer>::SerializeArray, <Serializer<'_, W> as Serializer>::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_seq_product( self, _len: usize, ) -> Result<<Serializer<'_, W> as Serializer>::SerializeSeqProduct, <Serializer<'_, W> as Serializer>::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<<Serializer<'_, W> as Serializer>::SerializeNamedProduct, <Serializer<'_, W> as Serializer>::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>( self, tag: u8, _name: Option<&str>, value: &T, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>
where T: Serialize + ?Sized,

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

unsafe fn serialize_bsatn<Ty>( self, ty: &Ty, bsatn: &[u8], ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>
where WithTypespace<'a, Ty>: for<'a, 'de> DeserializeSeed<'de>, <WithTypespace<'a, Ty> as DeserializeSeed<'de>>::Output: for<'a, 'de> Into<AlgebraicValue>,

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

unsafe fn serialize_bsatn_in_chunks<'a, Ty, I>( self, ty: &Ty, total_bsatn_len: usize, bsatn: I, ) -> Result<<Serializer<'_, W> as Serializer>::Ok, <Serializer<'_, W> as Serializer>::Error>
where I: Clone + Iterator<Item = &'a [u8]>, WithTypespace<'b, Ty>: for<'b, 'de> DeserializeSeed<'de>, <WithTypespace<'b, Ty> as DeserializeSeed<'de>>::Output: for<'b, 'de> Into<AlgebraicValue>,

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

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

Serialize the given string. Read more
Source§

fn serialize_named_product_raw( self, value: &ValueWithType<'_, ProductValue>, ) -> Result<Self::Ok, Self::Error>

Serialize a product with named fields. Read more
Source§

fn serialize_variant_raw( self, sum: &ValueWithType<'_, SumValue>, ) -> Result<Self::Ok, Self::Error>

Serialize a sum value Read more

Auto Trait Implementations§

§

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

§

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