Trait spacetimedb_lib::ser::Serializer
source · pub trait Serializer: Sized {
type Ok;
type Error: Error;
type SerializeArray: SerializeArray<Ok = Self::Ok, Error = Self::Error>;
type SerializeMap: SerializeMap<Ok = Self::Ok, Error = Self::Error>;
type SerializeSeqProduct: SerializeSeqProduct<Ok = Self::Ok, Error = Self::Error>;
type SerializeNamedProduct: SerializeNamedProduct<Ok = Self::Ok, Error = Self::Error>;
Show 20 methods
// Required methods
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>;
fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>;
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>;
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>;
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>;
fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>;
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>;
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>;
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>;
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>;
fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>;
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>;
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>;
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>;
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>;
fn serialize_array(
self,
len: usize
) -> Result<Self::SerializeArray, Self::Error>;
fn serialize_map(
self,
len: usize
) -> Result<Self::SerializeMap, Self::Error>;
fn serialize_seq_product(
self,
len: usize
) -> Result<Self::SerializeSeqProduct, Self::Error>;
fn serialize_named_product(
self,
len: usize
) -> Result<Self::SerializeNamedProduct, Self::Error>;
fn serialize_variant<T>(
self,
tag: u8,
name: Option<&str>,
value: &T
) -> Result<Self::Ok, Self::Error>
where T: Serialize + ?Sized;
}Expand description
A data format that can deserialize any data structure supported by SATs.
The Serializer trait in SATS performs the same function as serde::Serializer in serde.
See the documentation of serde::Serializer for more information of the data model.
Required Associated Types§
sourcetype 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.
sourcetype SerializeArray: SerializeArray<Ok = Self::Ok, Error = Self::Error>
type SerializeArray: SerializeArray<Ok = Self::Ok, Error = Self::Error>
Type returned from serialize_array
for serializing the contents of the array.
sourcetype SerializeMap: SerializeMap<Ok = Self::Ok, Error = Self::Error>
type SerializeMap: SerializeMap<Ok = Self::Ok, Error = Self::Error>
Type returned from serialize_map
for serializing the contents of the map.
sourcetype SerializeSeqProduct: SerializeSeqProduct<Ok = Self::Ok, Error = Self::Error>
type SerializeSeqProduct: SerializeSeqProduct<Ok = Self::Ok, Error = Self::Error>
Type returned from serialize_seq_product
for serializing the contents of the unnamed product.
sourcetype SerializeNamedProduct: SerializeNamedProduct<Ok = Self::Ok, Error = Self::Error>
type SerializeNamedProduct: SerializeNamedProduct<Ok = Self::Ok, Error = Self::Error>
Type returned from serialize_named_product
for serializing the contents of the named product.
Required Methods§
sourcefn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>
fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>
Serialize a &str string slice.
sourcefn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
Serialize a &[u8] byte slice.
sourcefn serialize_array(
self,
len: usize
) -> Result<Self::SerializeArray, Self::Error>
fn serialize_array( self, len: usize ) -> Result<Self::SerializeArray, Self::Error>
Begin to serialize a variably sized array.
This call must be followed by zero or more calls to SerializeArray::serialize_element,
then a call to SerializeArray::end.
The argument is the number of elements in the sequence.
sourcefn serialize_map(self, len: usize) -> Result<Self::SerializeMap, Self::Error>
fn serialize_map(self, len: usize) -> Result<Self::SerializeMap, Self::Error>
Begin to serialize a variably sized map.
This call must be followed by zero or more calls to [SerializeMap::serialize_element],
then a call to SerializeMap::end.
The argument is the number of elements in the map.
sourcefn serialize_seq_product(
self,
len: usize
) -> Result<Self::SerializeSeqProduct, Self::Error>
fn serialize_seq_product( self, len: usize ) -> Result<Self::SerializeSeqProduct, Self::Error>
Begin to serialize a product with unnamed fields.
This call must be followed by zero or more calls to SerializeSeqProduct::serialize_element,
then a call to SerializeSeqProduct::end.
The argument is the number of fields in the product.
sourcefn serialize_named_product(
self,
len: usize
) -> Result<Self::SerializeNamedProduct, Self::Error>
fn serialize_named_product( self, len: usize ) -> Result<Self::SerializeNamedProduct, Self::Error>
Begin to serialize a product with named fields.
This call must be followed by zero or more calls to SerializeNamedProduct::serialize_element,
then a call to SerializeNamedProduct::end.
The argument is the number of fields in the product.