[−][src]Function muon_rs::from_slice
pub fn from_slice<'a, T>(v: &'a [u8]) -> Result<T> where
T: Deserialize<'a>,
Deserialize T
from a byte slice containing MuON
Example
#[derive(Debug, Deserialize)] struct Person { name: String, born: u32, birthplace: Option<String>, } let muon = b"name: Arthur Schopenhauer\nborn: 1788\nbirthplace: Danzig\n"; let person: Person = muon_rs::from_slice(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 slice contains invalid UTF-8
- 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