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,

§

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>( &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> SerializeMap for Serializer<'_, W>where W: BufWriter,

§

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, V>( &mut self, key: &K, value: &V ) -> Result<(), <Serializer<'_, W> as SerializeMap>::Error>where K: Serialize + ?Sized, V: Serialize + ?Sized,

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

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

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

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

§

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

§

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<<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_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_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_map( self, len: usize ) -> Result<<Serializer<'_, W> as Serializer>::SerializeMap, <Serializer<'_, W> as Serializer>::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<<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.

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 Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.