Struct btserde::Serializer
source · pub struct Serializer<W: Write> { /* private fields */ }
Implementations§
source§impl<W: Write> Serializer<W>
impl<W: Write> Serializer<W>
pub fn new(write: W) -> Serializer<W>
Trait Implementations§
source§impl<'a, W: Write> SerializeMap for &'a mut Serializer<W>
impl<'a, W: Write> SerializeMap for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeSeq for &'a mut Serializer<W>
impl<'a, W: Write> SerializeSeq for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeStruct for &'a mut Serializer<W>
impl<'a, W: Write> SerializeStruct for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeStructVariant for &'a mut Serializer<W>
impl<'a, W: Write> SerializeStructVariant for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeTuple for &'a mut Serializer<W>
impl<'a, W: Write> SerializeTuple for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeTupleStruct for &'a mut Serializer<W>
impl<'a, W: Write> SerializeTupleStruct for &'a mut Serializer<W>
source§impl<'a, W: Write> SerializeTupleVariant for &'a mut Serializer<W>
impl<'a, W: Write> SerializeTupleVariant for &'a mut Serializer<W>
source§impl<'a, T: Write> Serializer for &'a mut Serializer<T>
impl<'a, T: Write> Serializer for &'a mut Serializer<T>
source§fn serialize_bool(self, v: bool) -> Result<Self::Ok>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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<()>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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 = ()
type Ok = ()
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 SerializeSeq = &'a mut Serializer<T>
type SerializeSeq = &'a mut Serializer<T>
serialize_seq
for serializing the content of the
sequence.§type SerializeTuple = &'a mut Serializer<T>
type SerializeTuple = &'a mut Serializer<T>
serialize_tuple
for serializing the content of
the tuple.§type SerializeTupleVariant = &'a mut Serializer<T>
type SerializeTupleVariant = &'a mut Serializer<T>
serialize_tuple_variant
for serializing the
content of the tuple variant.§type SerializeTupleStruct = &'a mut Serializer<T>
type SerializeTupleStruct = &'a mut Serializer<T>
serialize_tuple_struct
for serializing the
content of the tuple struct.§type SerializeMap = &'a mut Serializer<T>
type SerializeMap = &'a mut Serializer<T>
serialize_map
for serializing the content of the
map.§type SerializeStruct = &'a mut Serializer<T>
type SerializeStruct = &'a mut Serializer<T>
serialize_struct
for serializing the content of
the struct.§type SerializeStructVariant = &'a mut Serializer<T>
type SerializeStructVariant = &'a mut Serializer<T>
serialize_struct_variant
for serializing the
content of the struct variant.source§fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq>
fn serialize_seq(self, len: Option<usize>) -> Result<Self::SerializeSeq>
serialize_element
, then a call to
end
. Read moresource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Serialize
implementations should serialize in
human-readable form. Read more