Function deser_hjson::from_reader

source ·
pub fn from_reader<R, T>(reader: R) -> Result<T>where
    R: Read,
    T: DeserializeOwned,
Expand description

Deserialize an instance of type T from a reader of Hjson text

Example

use serde::Deserialize;
use std::io::Cursor;

#[derive(Deserialize, Debug)]
struct User {
    fingerprint: String,
    location: String,
}

// The type of `j` is `Cursor` which implements the `Read` trait
let j = Cursor::new("
    fingerprint: 0xF9BA143B95FF6D82
    location: Menlo Park, CA
");

let u: User = deser_hjson::from_reader(j).unwrap();
println!("{:#?}", u);