Function from_iter

Source
pub fn from_iter<T, I>(into_iter: I) -> NdjsonIter<T, I::IntoIter> 
where I: IntoIterator,
Available on crate feature iter only.
Expand description

Wraps an iterator of data blocks, i.e. types implementing AsBytes, obtained by IntoIterator::into_iter on into_iter and offers an Iterator implementation over parsed NDJSON-records according to Deserialize. The parser is configured with the default NdjsonConfig.

§Example

let data_blocks = vec![
    "123\n",
    "456\n789\n"
];

let mut ndjson_iter = ndjson_stream::from_iter::<u32, _>(data_blocks);

assert!(matches!(ndjson_iter.next(), Some(Ok(123))));
assert!(matches!(ndjson_iter.next(), Some(Ok(456))));
assert!(matches!(ndjson_iter.next(), Some(Ok(789))));
assert!(ndjson_iter.next().is_none());