[][src]Module toml::ser

Serializing Rust structures into TOML.

This module contains all the Serde support for serializing Rust structures into TOML documents (as strings). Note that some top-level functions here are also provided at the top of the crate.

Note that the TOML format has a restriction that if a table itself contains tables, all keys with non-table values must be emitted first. This is typically easy to ensure happens when you're defining a struct as you can reorder the fields manually, but when working with maps (such as BTreeMap or HashMap) this can lead to serialization errors. In those situations you may use the tables_last function in this module like so:

#[derive(Serialize)]
struct Manifest {
    package: Package,
    #[serde(serialize_with = "toml::ser::tables_last")]
    dependencies: HashMap<String, Dependency>,
}

Structs

Serializer

Serialization implementation for TOML.

Enums

Error

Errors that can occur when serializing a type.

Functions

tables_last

Convenience function to serialize items in a map in an order valid with TOML.

to_string

Serialize the given data structure as a String of TOML.

to_string_pretty

Serialize the given data structure as a "pretty" String of TOML.

to_vec

Serialize the given data structure as a TOML byte vector.