pub struct Serializer<'a> { /* private fields */ }Expand description
Serialize a single value.
The lifetime ’a is set by the serialization call site and the &'a mut
references used to return tracing results and serialization samples.
Implementations§
Trait Implementations§
Source§impl<'a> Serializer for Serializer<'a>
impl<'a> Serializer for Serializer<'a>
Source§type Ok = (Format, Value)
type Ok = (Format, Value)
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 = SeqSerializer<'a>
type SerializeSeq = SeqSerializer<'a>
Type returned from
serialize_seq for serializing the content of the
sequence.Source§type SerializeTuple = TupleSerializer<'a>
type SerializeTuple = TupleSerializer<'a>
Type returned from
serialize_tuple for serializing the content of
the tuple.Source§type SerializeTupleStruct = TupleStructSerializer<'a>
type SerializeTupleStruct = TupleStructSerializer<'a>
Type returned from
serialize_tuple_struct for serializing the
content of the tuple struct.Source§type SerializeTupleVariant = TupleVariantSerializer<'a>
type SerializeTupleVariant = TupleVariantSerializer<'a>
Type returned from
serialize_tuple_variant for serializing the
content of the tuple variant.Source§type SerializeMap = MapSerializer<'a>
type SerializeMap = MapSerializer<'a>
Type returned from
serialize_map for serializing the content of the
map.Source§type SerializeStruct = StructSerializer<'a>
type SerializeStruct = StructSerializer<'a>
Type returned from
serialize_struct for serializing the content of
the struct.Source§type SerializeStructVariant = StructVariantSerializer<'a>
type SerializeStructVariant = StructVariantSerializer<'a>
Type returned from
serialize_struct_variant for serializing the
content of the struct variant.Source§fn serialize_bool(self, content: bool) -> Result<(Format, Value)>
fn serialize_bool(self, content: bool) -> Result<(Format, Value)>
Serialize a
bool value. Read moreSource§fn serialize_i8(self, content: i8) -> Result<(Format, Value)>
fn serialize_i8(self, content: i8) -> Result<(Format, Value)>
Serialize an
i8 value. Read moreSource§fn serialize_i16(self, content: i16) -> Result<(Format, Value)>
fn serialize_i16(self, content: i16) -> Result<(Format, Value)>
Serialize an
i16 value. Read moreSource§fn serialize_i32(self, content: i32) -> Result<(Format, Value)>
fn serialize_i32(self, content: i32) -> Result<(Format, Value)>
Serialize an
i32 value. Read moreSource§fn serialize_i64(self, content: i64) -> Result<(Format, Value)>
fn serialize_i64(self, content: i64) -> Result<(Format, Value)>
Serialize an
i64 value. Read moreSource§fn serialize_i128(self, content: i128) -> Result<(Format, Value)>
fn serialize_i128(self, content: i128) -> Result<(Format, Value)>
Serialize an
i128 value. Read moreSource§fn serialize_u16(self, content: u16) -> Result<(Format, Value)>
fn serialize_u16(self, content: u16) -> Result<(Format, Value)>
Serialize a
u16 value. Read moreSource§fn serialize_u32(self, content: u32) -> Result<(Format, Value)>
fn serialize_u32(self, content: u32) -> Result<(Format, Value)>
Serialize a
u32 value. Read moreSource§fn serialize_u64(self, content: u64) -> Result<(Format, Value)>
fn serialize_u64(self, content: u64) -> Result<(Format, Value)>
Serialize a
u64 value. Read moreSource§fn serialize_u128(self, content: u128) -> Result<(Format, Value)>
fn serialize_u128(self, content: u128) -> Result<(Format, Value)>
Serialize a
u128 value. Read moreSource§fn serialize_f32(self, content: f32) -> Result<(Format, Value)>
fn serialize_f32(self, content: f32) -> Result<(Format, Value)>
Serialize an
f32 value. Read moreSource§fn serialize_f64(self, content: f64) -> Result<(Format, Value)>
fn serialize_f64(self, content: f64) -> Result<(Format, Value)>
Serialize an
f64 value. Read moreSource§fn serialize_char(self, content: char) -> Result<(Format, Value)>
fn serialize_char(self, content: char) -> Result<(Format, Value)>
Serialize a character. Read more
Source§fn serialize_bytes(self, content: &[u8]) -> Result<(Format, Value)>
fn serialize_bytes(self, content: &[u8]) -> Result<(Format, Value)>
Serialize a chunk of raw byte data. Read more
Source§fn serialize_unit_variant(
self,
name: &'static str,
variant_index: u32,
variant_name: &'static str,
) -> Result<(Format, Value)>
fn serialize_unit_variant( self, name: &'static str, variant_index: u32, variant_name: &'static str, ) -> Result<(Format, Value)>
Source§fn serialize_newtype_struct<T>(
self,
name: &'static str,
content: &T,
) -> Result<(Format, Value)>
fn serialize_newtype_struct<T>( self, name: &'static str, content: &T, ) -> Result<(Format, Value)>
Serialize a newtype struct like
struct Millimeters(u8). Read moreSource§fn serialize_newtype_variant<T>(
self,
name: &'static str,
variant_index: u32,
variant_name: &'static str,
content: &T,
) -> Result<(Format, Value)>
fn serialize_newtype_variant<T>( self, name: &'static str, variant_index: u32, variant_name: &'static str, content: &T, ) -> Result<(Format, Value)>
Source§fn serialize_seq(self, _len: Option<usize>) -> Result<Self::SerializeSeq>
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 moreSource§fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple>
fn serialize_tuple(self, _len: usize) -> Result<Self::SerializeTuple>
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>
fn serialize_tuple_struct( self, name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleStruct>
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_name: &'static str,
_len: usize,
) -> Result<Self::SerializeTupleVariant>
fn serialize_tuple_variant( self, name: &'static str, variant_index: u32, variant_name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleVariant>
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>
fn serialize_map(self, _len: Option<usize>) -> Result<Self::SerializeMap>
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>
fn serialize_struct( self, name: &'static str, _len: usize, ) -> Result<Self::SerializeStruct>
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_name: &'static str,
_len: usize,
) -> Result<Self::SerializeStructVariant>
fn serialize_struct_variant( self, name: &'static str, variant_index: u32, variant_name: &'static str, _len: usize, ) -> Result<Self::SerializeStructVariant>
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 is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Determine whether
Serialize implementations should serialize in
human-readable form. 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
Auto Trait Implementations§
impl<'a> Freeze for Serializer<'a>
impl<'a> !RefUnwindSafe for Serializer<'a>
impl<'a> !Send for Serializer<'a>
impl<'a> !Sync for Serializer<'a>
impl<'a> Unpin for Serializer<'a>
impl<'a> !UnwindSafe for Serializer<'a>
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