Function renvy::deserialize
source · [−]Expand description
Parses a String into an object of type Settings
.
This function parses a string that consists of newline-separated lines. Each line
must be one Key-Value pair, where the key is separated from the value with a =
.
This function is the opposite of serialize()
.
Example
Each key-value pair is being parsed into one entry. All pairs are collected in one variable of type renvy::Settings.
let input = String::from("url=https://example.com\n");
let deserialized = renvy::deserialize(&input);
assert_eq!(deserialized.get("url").unwrap(), &Some(String::from("https://example.com")));
Lines without values will be deserialized correctly, too:
let input = String::from("url=\n");
let deserialized = renvy::deserialize(&input);
assert_eq!(deserialized.get("url").unwrap(), &None);