Expand description
Produces a String representation of a Settings
object which can be written to disk.
This function produces a string that consists of newline-separated lines. Each line
corresponds to one Key-Value pair, where the key is separated from the value with a =
.
This function is the opposite of deserialize()
.
Example
Each key-value pair is being serialized into Strings separated by =
. All pairs
are concatenated by newlines:
let settings = renvy::Settings::from([("url".into(), Some(String::from("https://example.com")))]);
let serialized = renvy::serialize(&settings);
assert_eq!(serialized, String::from("url=https://example.com\n"));
Settings without values will be serialized correctly, too:
let settings = renvy::Settings::from([("url".into(), None)]);
let serialized = renvy::serialize(&settings);
assert_eq!(serialized, String::from("url=\n"));