Struct Serializer

struct Serializer<'d> { ... }

Serialization for TOML documents.

This structure implements serialization support for TOML to serialize an arbitrary type to TOML. Note that the TOML format does not support all datatypes in Rust, such as enums, tuples, and tuple structs. These types will generate an error when serialized.

Currently a serializer always writes its output to an in-memory String, which is passed in when creating the serializer itself.

To serialize TOML values, instead of documents, see [ValueSerializer][super::value::ValueSerializer].

Implementations

impl<'d> Serializer<'d>

fn new(buf: &'d mut Buffer) -> Self

Creates a new serializer which will emit TOML into the buffer provided.

The serializer can then be used to serialize a type after which the data will be present in buf.

fn pretty(buf: &'d mut Buffer) -> Self

Apply a default "pretty" policy to the document

For greater customization, instead serialize to a toml_edit::DocumentMut.

impl<'d> Freeze for Serializer<'d>

impl<'d> RefUnwindSafe for Serializer<'d>

impl<'d> Send for Serializer<'d>

impl<'d> Serializer for Serializer<'d>

fn serialize_bool(self: Self, _v: bool) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_i8(self: Self, _v: i8) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_i16(self: Self, _v: i16) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_i32(self: Self, _v: i32) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_i64(self: Self, _v: i64) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_u8(self: Self, _v: u8) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_u16(self: Self, _v: u16) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_u32(self: Self, _v: u32) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_u64(self: Self, _v: u64) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_f32(self: Self, _v: f32) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_f64(self: Self, _v: f64) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_char(self: Self, _v: char) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_str(self: Self, _v: &str) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_bytes(self: Self, _v: &[u8]) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_none(self: Self) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_some<T>(self: Self, v: &T) -> Result<<Self as >::Ok, <Self as >::Error>
where
    T: Serialize + ?Sized
fn serialize_unit(self: Self) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_unit_struct(self: Self, name: &'static str) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_unit_variant(self: Self, name: &'static str, _variant_index: u32, _variant: &'static str) -> Result<<Self as >::Ok, <Self as >::Error>
fn serialize_newtype_struct<T>(self: Self, _name: &'static str, v: &T) -> Result<<Self as >::Ok, <Self as >::Error>
where
    T: Serialize + ?Sized
fn serialize_newtype_variant<T>(self: Self, _name: &'static str, _variant_index: u32, variant: &'static str, value: &T) -> Result<<Self as >::Ok, <Self as >::Error>
where
    T: Serialize + ?Sized
fn serialize_seq(self: Self, _len: Option<usize>) -> Result<<Self as >::SerializeSeq, <Self as >::Error>
fn serialize_tuple(self: Self, len: usize) -> Result<<Self as >::SerializeTuple, <Self as >::Error>
fn serialize_tuple_struct(self: Self, _name: &'static str, len: usize) -> Result<<Self as >::SerializeTupleStruct, <Self as >::Error>
fn serialize_tuple_variant(self: Self, _name: &'static str, _variant_index: u32, variant: &'static str, len: usize) -> Result<<Self as >::SerializeTupleVariant, <Self as >::Error>
fn serialize_map(self: Self, _len: Option<usize>) -> Result<<Self as >::SerializeMap, <Self as >::Error>
fn serialize_struct(self: Self, _name: &'static str, len: usize) -> Result<<Self as >::SerializeStruct, <Self as >::Error>
fn serialize_struct_variant(self: Self, _name: &'static str, _variant_index: u32, variant: &'static str, _len: usize) -> Result<<Self as >::SerializeStructVariant, <Self as >::Error>

impl<'d> Sync for Serializer<'d>

impl<'d> Unpin for Serializer<'d>

impl<'d> UnsafeUnpin for Serializer<'d>

impl<'d> UnwindSafe for Serializer<'d>

impl<T> Any for Serializer<'d>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Serializer<'d>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Serializer<'d>

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> From for Serializer<'d>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Serializer<'d>

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Serializer<'d>

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Serializer<'d>

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>