Struct fuel_indexer_utils::prelude::serde_json::ser::Serializer
source · pub struct Serializer<W, F = CompactFormatter> { /* private fields */ }
Expand description
A structure for serializing Rust values into JSON.
Implementations§
source§impl<W> Serializer<W>where
W: Write,
impl<W> Serializer<W>where
W: Write,
sourcepub fn new(writer: W) -> Serializer<W>
pub fn new(writer: W) -> Serializer<W>
Creates a new JSON serializer.
source§impl<'a, W> Serializer<W, PrettyFormatter<'a>>where
W: Write,
impl<'a, W> Serializer<W, PrettyFormatter<'a>>where
W: Write,
sourcepub fn pretty(writer: W) -> Serializer<W, PrettyFormatter<'a>>
pub fn pretty(writer: W) -> Serializer<W, PrettyFormatter<'a>>
Creates a new JSON pretty print serializer.
source§impl<W, F> Serializer<W, F>
impl<W, F> Serializer<W, F>
sourcepub fn with_formatter(writer: W, formatter: F) -> Serializer<W, F>
pub fn with_formatter(writer: W, formatter: F) -> Serializer<W, F>
Creates a new JSON visitor whose output will be written to the writer specified.
sourcepub fn into_inner(self) -> W
pub fn into_inner(self) -> W
Unwrap the Writer
from the Serializer
.
Trait Implementations§
source§impl<'a, W, F> Serializer for &'a mut Serializer<W, F>
impl<'a, W, F> Serializer for &'a mut Serializer<W, F>
source§fn serialize_newtype_struct<T>(
self,
_name: &'static str,
value: &T
) -> Result<(), Error>
fn serialize_newtype_struct<T>( self, _name: &'static str, value: &T ) -> Result<(), Error>
Serialize newtypes without an object wrapper.
§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.§type SerializeSeq = Compound<'a, W, F>
type SerializeSeq = Compound<'a, W, F>
Type returned from
serialize_seq
for serializing the content of the
sequence.§type SerializeTuple = Compound<'a, W, F>
type SerializeTuple = Compound<'a, W, F>
Type returned from
serialize_tuple
for serializing the content of
the tuple.§type SerializeTupleStruct = Compound<'a, W, F>
type SerializeTupleStruct = Compound<'a, W, F>
Type returned from
serialize_tuple_struct
for serializing the
content of the tuple struct.§type SerializeTupleVariant = Compound<'a, W, F>
type SerializeTupleVariant = Compound<'a, W, F>
Type returned from
serialize_tuple_variant
for serializing the
content of the tuple variant.§type SerializeMap = Compound<'a, W, F>
type SerializeMap = Compound<'a, W, F>
Type returned from
serialize_map
for serializing the content of the
map.§type SerializeStruct = Compound<'a, W, F>
type SerializeStruct = Compound<'a, W, F>
Type returned from
serialize_struct
for serializing the content of
the struct.§type SerializeStructVariant = Compound<'a, W, F>
type SerializeStructVariant = Compound<'a, W, F>
Type returned from
serialize_struct_variant
for serializing the
content of the struct variant.source§fn serialize_bytes(self, value: &[u8]) -> Result<(), Error>
fn serialize_bytes(self, value: &[u8]) -> Result<(), Error>
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<(), Error>
fn serialize_unit_variant( self, _name: &'static str, _variant_index: u32, variant: &'static str ) -> Result<(), Error>
source§fn serialize_newtype_variant<T>(
self,
_name: &'static str,
_variant_index: u32,
variant: &'static str,
value: &T
) -> Result<(), Error>
fn serialize_newtype_variant<T>( self, _name: &'static str, _variant_index: u32, variant: &'static str, value: &T ) -> Result<(), Error>
source§fn serialize_seq(
self,
len: Option<usize>
) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeSeq, Error>
fn serialize_seq( self, len: Option<usize> ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeSeq, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeTuple, Error>
fn serialize_tuple( self, len: usize ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeTuple, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeTupleStruct, Error>
fn serialize_tuple_struct( self, _name: &'static str, len: usize ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeTupleStruct, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeTupleVariant, Error>
fn serialize_tuple_variant( self, _name: &'static str, _variant_index: u32, variant: &'static str, len: usize ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeTupleVariant, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeMap, Error>
fn serialize_map( self, len: Option<usize> ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeMap, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeStruct, Error>
fn serialize_struct( self, name: &'static str, len: usize ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeStruct, Error>
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<<&'a mut Serializer<W, F> as Serializer>::SerializeStructVariant, Error>
fn serialize_struct_variant( self, _name: &'static str, _variant_index: u32, variant: &'static str, len: usize ) -> Result<<&'a mut Serializer<W, F> as Serializer>::SerializeStructVariant, Error>
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_str<T>(self, value: &T) -> Result<(), Error>
fn collect_str<T>(self, value: &T) -> Result<(), Error>
Serialize a string produced by an implementation of
Display
. 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 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<W, F> RefUnwindSafe for Serializer<W, F>where
F: RefUnwindSafe,
W: RefUnwindSafe,
impl<W, F> Send for Serializer<W, F>
impl<W, F> Sync for Serializer<W, F>
impl<W, F> Unpin for Serializer<W, F>
impl<W, F> UnwindSafe for Serializer<W, F>where
F: UnwindSafe,
W: UnwindSafe,
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
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
Causes
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
Causes
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
Causes
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
Causes
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
Causes
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
Causes
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
Causes
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
Causes
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
Formats each item in a sequence. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Pipes by value. This is generally the method you want to use. Read more
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
Borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
Mutably borrows
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
Borrows
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
Mutably borrows
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
Borrows
self
, then passes self.deref()
into the pipe function.§impl<T> StorageAsMut for T
impl<T> StorageAsMut for T
fn storage<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
fn storage_as_mut<Type>(&mut self) -> StorageMut<'_, Self, Type>where
Type: Mappable,
§impl<T> StorageAsRef for T
impl<T> StorageAsRef for T
fn storage<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
fn storage_as_ref<Type>(&self) -> StorageRef<'_, Self, Type>where
Type: Mappable,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Immutable access to the
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
Mutable access to the
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
Immutable access to the
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
Mutable access to the
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Immutable access to the
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Mutable access to the
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
Calls
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
Calls
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
Calls
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
Calls
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
Calls
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
Calls
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
Calls
.tap_deref()
only in debug builds, and is erased in release
builds.