Skip to main content

from_reader

Function from_reader 

Source
pub fn from_reader<R, T>(reader: R) -> Result<T>
where R: Read, T: for<'de> Deserialize<'de> + 'static,
Available on crate feature std only.
Expand description

Deserialize YAML from an std::io::Read source.

Reads the entire stream into memory before parsing — YAML’s data model is not streamable past document boundaries, so this function trades incremental I/O for a single, simple Result. For very large multi-document streams prefer crate::parallel::parse (with the parallel feature) which scans document boundaries on the input thread and parses each document in parallel.

§Errors

  • Error::Io — the underlying reader returns an I/O error while filling the buffer.
  • All variants documented on from_str.

§Examples

let yaml = b"42".to_vec();
let n: i32 = noyalib::from_reader(&yaml[..]).unwrap();
assert_eq!(n, 42);