pub struct SimpleSerializer { /* private fields */ }Expand description
A minimal binary serializer implementing serde::Serializer.
Writes values to an internal byte buffer using a compact big-endian format.
Implementations§
Source§impl SimpleSerializer
impl SimpleSerializer
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Creates a new serializer with a pre-allocated buffer.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consumes the serializer and returns the serialized bytes.
Trait Implementations§
Source§impl Default for SimpleSerializer
impl Default for SimpleSerializer
Source§impl SerializeMap for &mut SimpleSerializer
impl SerializeMap for &mut SimpleSerializer
Source§impl SerializeSeq for &mut SimpleSerializer
impl SerializeSeq for &mut SimpleSerializer
Source§impl SerializeStruct for &mut SimpleSerializer
impl SerializeStruct for &mut SimpleSerializer
Source§impl SerializeStructVariant for &mut SimpleSerializer
impl SerializeStructVariant for &mut SimpleSerializer
Source§impl SerializeTuple for &mut SimpleSerializer
impl SerializeTuple for &mut SimpleSerializer
Source§impl SerializeTupleStruct for &mut SimpleSerializer
impl SerializeTupleStruct for &mut SimpleSerializer
Source§impl SerializeTupleVariant for &mut SimpleSerializer
impl SerializeTupleVariant for &mut SimpleSerializer
Source§impl Serializer for &mut SimpleSerializer
impl Serializer for &mut SimpleSerializer
Source§type Ok = ()
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.Source§type SerializeSeq = &mut SimpleSerializer
type SerializeSeq = &mut SimpleSerializer
Type returned from
serialize_seq for serializing the content of the
sequence.Source§type SerializeTuple = &mut SimpleSerializer
type SerializeTuple = &mut SimpleSerializer
Type returned from
serialize_tuple for serializing the content of
the tuple.Source§type SerializeTupleStruct = &mut SimpleSerializer
type SerializeTupleStruct = &mut SimpleSerializer
Type returned from
serialize_tuple_struct for serializing the
content of the tuple struct.Source§type SerializeTupleVariant = &mut SimpleSerializer
type SerializeTupleVariant = &mut SimpleSerializer
Type returned from
serialize_tuple_variant for serializing the
content of the tuple variant.Source§type SerializeMap = &mut SimpleSerializer
type SerializeMap = &mut SimpleSerializer
Type returned from
serialize_map for serializing the content of the
map.Source§type SerializeStruct = &mut SimpleSerializer
type SerializeStruct = &mut SimpleSerializer
Type returned from
serialize_struct for serializing the content of
the struct.Source§type SerializeStructVariant = &mut SimpleSerializer
type SerializeStructVariant = &mut SimpleSerializer
Type returned from
serialize_struct_variant for serializing the
content of the struct variant.Source§fn serialize_bytes(self, v: &[u8]) -> Result<(), SerError>
fn serialize_bytes(self, v: &[u8]) -> Result<(), SerError>
Serialize a chunk of raw byte data. Read more
Source§fn serialize_unit_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
) -> Result<(), SerError>
fn serialize_unit_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, ) -> Result<(), SerError>
Source§fn serialize_newtype_struct<T: ?Sized + Serialize>(
self,
_name: &'static str,
value: &T,
) -> Result<(), SerError>
fn serialize_newtype_struct<T: ?Sized + Serialize>( self, _name: &'static str, value: &T, ) -> Result<(), SerError>
Serialize a newtype struct like
struct Millimeters(u8). Read moreSource§fn serialize_newtype_variant<T: ?Sized + Serialize>(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
value: &T,
) -> Result<(), SerError>
fn serialize_newtype_variant<T: ?Sized + Serialize>( self, _name: &'static str, variant_index: u32, _variant: &'static str, value: &T, ) -> Result<(), SerError>
Source§fn serialize_seq(
self,
len: Option<usize>,
) -> Result<Self::SerializeSeq, SerError>
fn serialize_seq( self, len: Option<usize>, ) -> Result<Self::SerializeSeq, SerError>
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 moreSource§fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, SerError>
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple, SerError>
Begin to serialize a statically sized sequence whose length will be
known at deserialization time without looking at the serialized data.
This call must be followed by zero or more calls to
serialize_element,
then a call to end. Read moreSource§fn serialize_tuple_struct(
self,
_name: &'static str,
_len: usize,
) -> Result<Self::SerializeTupleStruct, SerError>
fn serialize_tuple_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleStruct, SerError>
Begin to serialize a tuple struct like
struct Rgb(u8, u8, u8). This
call must be followed by zero or more calls to serialize_field, then a
call to end. Read moreSource§fn serialize_tuple_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
_len: usize,
) -> Result<Self::SerializeTupleVariant, SerError>
fn serialize_tuple_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeTupleVariant, SerError>
Begin to serialize a tuple variant like
E::T in enum E { T(u8, u8) }. This call must be followed by zero or more calls to
serialize_field, then a call to end. Read moreSource§fn serialize_map(
self,
len: Option<usize>,
) -> Result<Self::SerializeMap, SerError>
fn serialize_map( self, len: Option<usize>, ) -> Result<Self::SerializeMap, SerError>
Begin to serialize a map. This call must be followed by zero or more
calls to
serialize_key and serialize_value, then a call to end. Read moreSource§fn serialize_struct(
self,
_name: &'static str,
_len: usize,
) -> Result<Self::SerializeStruct, SerError>
fn serialize_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeStruct, SerError>
Begin to serialize a struct like
struct Rgb { r: u8, g: u8, b: u8 }.
This call must be followed by zero or more calls to serialize_field,
then a call to end. Read moreSource§fn serialize_struct_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
_len: usize,
) -> Result<Self::SerializeStructVariant, SerError>
fn serialize_struct_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeStructVariant, SerError>
Begin to serialize a struct variant like
E::S in enum E { S { r: u8, g: u8, b: u8 } }. This call must be followed by zero or more calls to
serialize_field, then a call to end. Read moreSource§fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
Collect an iterator as a sequence. Read more
Source§fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
Collect an iterator as a map. Read more
Source§fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
Serialize a string produced by an implementation of
Display. Read moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Serialize implementations should serialize in
human-readable form. Read moreAuto Trait Implementations§
impl Freeze for SimpleSerializer
impl RefUnwindSafe for SimpleSerializer
impl Send for SimpleSerializer
impl Sync for SimpleSerializer
impl Unpin for SimpleSerializer
impl UnsafeUnpin for SimpleSerializer
impl UnwindSafe for SimpleSerializer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more