Struct btserde::Serializer

source ·
pub struct Serializer<W: Write> { /* private fields */ }

Implementations§

source§

impl<W: Write> Serializer<W>

source

pub fn new(write: W) -> Serializer<W>

Trait Implementations§

source§

impl<'a, W: Write> SerializeMap for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_key<U: ?Sized + Serialize>(&mut self, key: &U) -> Result<()>

Serialize a map key. Read more
source§

fn serialize_value<U: ?Sized + Serialize>(&mut self, value: &U) -> Result<()>

Serialize a map value. Read more
source§

fn end(self) -> Result<()>

Finish serializing a map.
source§

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

Serialize a map entry consisting of a key and a value. Read more
source§

impl<'a, W: Write> SerializeSeq for &'a mut Serializer<W>

source§

fn end(self) -> Result<()>

No marker is added to the end of the sequence because we know its length.

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_element<U: ?Sized + Serialize>(&mut self, value: &U) -> Result<()>

Serialize a sequence element.
source§

impl<'a, W: Write> SerializeStruct for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_field<U: ?Sized + Serialize>( &mut self, _key: &'static str, value: &U ) -> Result<()>

Serialize a struct field.
source§

fn end(self) -> Result<()>

Finish serializing a struct.
source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct field has been skipped.
source§

impl<'a, W: Write> SerializeStructVariant for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_field<U: ?Sized + Serialize>( &mut self, _key: &'static str, value: &U ) -> Result<()>

Serialize a struct variant field.
source§

fn end(self) -> Result<()>

Finish serializing a struct variant.
source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct variant field has been skipped.
source§

impl<'a, W: Write> SerializeTuple for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_element<U: ?Sized + Serialize>(&mut self, value: &U) -> Result<()>

Serialize a tuple element.
source§

fn end(self) -> Result<()>

Finish serializing a tuple.
source§

impl<'a, W: Write> SerializeTupleStruct for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_field<U: ?Sized + Serialize>(&mut self, value: &U) -> Result<()>

Serialize a tuple struct field.
source§

fn end(self) -> Result<()>

Finish serializing a tuple struct.
source§

impl<'a, W: Write> SerializeTupleVariant for &'a mut Serializer<W>

§

type Ok = ()

Must match the Ok type of our Serializer.
§

type Error = Error

Must match the Error type of our Serializer.
source§

fn serialize_field<U: ?Sized + Serialize>(&mut self, value: &U) -> Result<()>

Serialize a tuple variant field.
source§

fn end(self) -> Result<()>

Finish serializing a tuple variant.
source§

impl<'a, T: Write> Serializer for &'a mut Serializer<T>

source§

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

A bool is serialized by writing the byte 1 if true and 0 if false.

source§

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

The output format of a signed byte is two’s complement, so we can just output Rust’s binary representation.

source§

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

The output format of a signed integer is two’s complement, so we can just output Rust’s binary representation in little endian order.

source§

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

The output format of a signed integer is two’s complement, so we can just output Rust’s binary representation in little endian order.

source§

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

The output format of a signed integer is two’s complement, so we can just output Rust’s binary representation in little endian order.

source§

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

The output format of a signed integer is two’s complement, so we can just output Rust’s binary representation in little endian order.

source§

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

The given byte is written directly to the output.

source§

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

The underlying bytes of the given unsigned integer are written to the output in little endian order.

source§

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

The underlying bytes of the given unsigned integer are written to the output in little endian order.

source§

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

The underlying bytes of the given unsigned integer are written to the output in little endian order.

source§

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

The underlying bytes of the given unsigned integer are written to the output in little endian order.

source§

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

Since the output format is IEEE 754, we can just write the underlying bytes to the output in little endian order.

source§

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

Since the output format is IEEE 754, we can just write the underlying bytes to the output in little endian order.

source§

fn serialize_char(self, c: char) -> Result<Self::Ok>

The given char is cast to a u8 then written to the output.

source§

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

A slice of bytes is stored by first writing its length (in LE order) and then the slice.

source§

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

A str is just serialized as a sequence of UTF8 bytes.

source§

fn serialize_none(self) -> Result<Self::Ok>

The none variant is stored by serializing false.

source§

fn serialize_some<U: ?Sized + Serialize>(self, value: &U) -> Result<Self::Ok>

A some variant is stored by serializing true before the of its value.

source§

fn serialize_unit(self) -> Result<()>

The unit is a type which can be represented with zero bytes, so we faithfully represent it as nothing.

source§

fn serialize_unit_struct(self, _name: &'static str) -> Result<Self::Ok>

Forwards to serialize_unit.

source§

fn serialize_unit_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str ) -> Result<Self::Ok>

The index of the unit variant is written to the output.

source§

fn serialize_newtype_struct<U: ?Sized + Serialize>( self, _name: &'static str, value: &U ) -> Result<Self::Ok>

The value of the newtype struct is serialized and its name is ignored.

source§

fn serialize_newtype_variant<U: ?Sized + Serialize>( self, _name: &'static str, variant_index: u32, _variant: &'static str, value: &U ) -> Result<Self::Ok>

The index of the variant is serialized and written out, followed by the serialization of its value.

source§

fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple>

A tuple’s length is not stored, only its entries.

source§

fn serialize_tuple_struct( self, _name: &'static str, _len: usize ) -> Result<Self::SerializeTupleStruct>

A tuple struct is serialized the same way as a tuple, its name is ignore.

source§

fn serialize_tuple_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize ) -> Result<Self::SerializeTupleStruct>

The variant index is stored before the tuples values.

source§

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

The number of entries in the map is stored as a u32 prior to serializing the key value pairs in the map. If there are more entries than a u32 can represent, then an error is returned.

source§

fn serialize_struct( self, _name: &'static str, _len: usize ) -> Result<Self::SerializeStruct>

Since the members of a struct a known at compile time, no additional information is stored.

source§

fn serialize_struct_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize ) -> Result<Self::SerializeStructVariant>

The variant index is stored before the struct’s members.

§

type Ok = ()

The output type produced by this Serializer during successful serialization. Most serializers that produce text or binary output should set Ok = () and serialize into an io::Write or buffer contained within the Serializer instance. Serializers that build in-memory data structures may be simplified by using Ok to propagate the data structure around.
§

type Error = Error

The error type when some error occurs during serialization.
§

type SerializeSeq = &'a mut Serializer<T>

Type returned from serialize_seq for serializing the content of the sequence.
§

type SerializeTuple = &'a mut Serializer<T>

Type returned from serialize_tuple for serializing the content of the tuple.
§

type SerializeTupleVariant = &'a mut Serializer<T>

Type returned from serialize_tuple_variant for serializing the content of the tuple variant.
§

type SerializeTupleStruct = &'a mut Serializer<T>

Type returned from serialize_tuple_struct for serializing the content of the tuple struct.
§

type SerializeMap = &'a mut Serializer<T>

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

type SerializeStruct = &'a mut Serializer<T>

Type returned from serialize_struct for serializing the content of the struct.
§

type SerializeStructVariant = &'a mut Serializer<T>

Type returned from serialize_struct_variant for serializing the content of the struct variant.
source§

fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq>

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

fn is_human_readable(&self) -> bool

Determine whether Serialize implementations should serialize in human-readable form. Read more
source§

fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>where I: IntoIterator, <I as IntoIterator>::Item: Serialize,

Collect an iterator as a sequence. Read more
source§

fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>where K: Serialize, V: Serialize, I: IntoIterator<Item = (K, V)>,

Collect an iterator as a map. Read more
source§

fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>where T: Display + ?Sized,

Serialize a string produced by an implementation of Display. Read more

Auto Trait Implementations§

§

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

§

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

§

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

§

impl<W> Unpin for Serializer<W>where W: Unpin,

§

impl<W> UnwindSafe for Serializer<W>where W: UnwindSafe,

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