[−][src]Module sane::ser
Serializing Rust structures into SANE.
This module contains all the Serde support for serializing Rust structures into SANE documents (as strings). Note that some top-level functions here are also provided at the top of the crate.
Note that the SANE 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 = "sane::ser::tables_last")] dependencies: HashMap<String, Dependency>, }
Structs
Serializer | Serialization implementation for SANE. |
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 SANE. |
to_string | Serialize the given data structure as a String of SANE. |
to_string_pretty | Serialize the given data structure as a "pretty" String of SANE. |
to_vec | Serialize the given data structure as a SANE byte vector. |