pub trait SerializeString {
// Required methods
fn serialize_utf8(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>;
fn serialize_utf16_be(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>;
fn serialize_utf16_le(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>;
}
Expand description
A trait for serializing strings into various encodings and with optional length fields.
Required Methods§
Sourcefn serialize_utf8(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>
fn serialize_utf8( &self, ser: &mut Serializer<'_>, len: Option<LengthField>, ) -> Result<()>
Serialize the string into UTF-8 encoding.
This function serializes the string into UTF-8 encoding and writes it to the
provided Serializer
. If a LengthField
is specified, the length of the
serialized string can be prepended before the actual data.
§Errors
This function will return an error if serialization fails.
Sourcefn serialize_utf16_be(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>
fn serialize_utf16_be( &self, ser: &mut Serializer<'_>, len: Option<LengthField>, ) -> Result<()>
Serialize the string into UTF-16 encoding with big-endian byte order.
This function serializes the string into UTF-16 encoding with big-endian byte
order and writes it to the provided Serializer
. If a LengthField
is
specified, the length of the serialized string can be prepended before the
actual data.
§Errors
This function will return an error if serialization fails.
Sourcefn serialize_utf16_le(
&self,
ser: &mut Serializer<'_>,
len: Option<LengthField>,
) -> Result<()>
fn serialize_utf16_le( &self, ser: &mut Serializer<'_>, len: Option<LengthField>, ) -> Result<()>
Serialize the string into UTF-16 encoding with little-endian byte order.
This function serializes the string into UTF-16 encoding with little-endian byte
order and writes it to the provided Serializer
. If a LengthField
is
specified, the length of the serialized string can be prepended before the
actual data.
§Errors
This function will return an error if serialization fails.