Module toml::ser[][src]

Expand description

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

Serialization implementation for TOML.

Enums

Errors that can occur when serializing a type.

Functions

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

Serialize the given data structure as a String of TOML.

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

Serialize the given data structure as a TOML byte vector.