pub fn from_str<T: DeserializeOwned>(input: &str) -> Result<T>Expand description
Deserialize an instance of T from a structprop-formatted string.
The entire input is parsed into a Value tree first, then the tree is
driven through serde’s visitor protocol to produce a T.
§Errors
Returns Error::Parse if the input is not valid structprop, or a
Error::Message variant if the deserialized data does not match the
expected shape of T.
§Examples
use serde::Deserialize;
use serde_structprop::from_str;
#[derive(Deserialize, PartialEq, Debug)]
struct Config { host: String, port: u16 }
let cfg: Config = from_str("host = localhost\nport = 9000\n").unwrap();
assert_eq!(cfg.host, "localhost");
assert_eq!(cfg.port, 9000);