[][src]Function muon_rs::from_str

pub fn from_str<'a, T>(s: &'a str) -> Result<T> where
    T: Deserialize<'a>, 

Deserialize T from a string slice containing MuON

Example

#[derive(Debug, Deserialize)]
struct Person {
    name: String,
    born: u32,
    birthplace: Option<String>,
}
let muon = "name: Arthur Schopenhauer\nborn: 1788\nbirthplace: Danzig\n";
let person: Person = muon_rs::from_str(muon).unwrap();
println!("{:?}", person);

Errors

An error will be returned if the conversion cannot be performed. This can occur for a number of reasons:

  • The MuON data is malformed
  • The structure of the MuON data does not match the structure of T
  • A required field is missing
  • A value is too big to fit within a primitive defined by T