Crates.io | streamson-generator |
lib.rs | streamson-generator |
version | 7.1.0 |
source | src |
created_at | 2020-10-04 22:25:39.456628 |
updated_at | 2021-05-10 20:20:29.69915 |
description | A library which integrates streamson with generators |
homepage | |
repository | https://github.com/shenek/streamson |
max_upload_size | |
id | 296162 |
size | 10,585 |
A library which integrates streamson with rust generators.
let mut file = fs::File::open("/tmp/large.json")?;
let mut input_generator = move || {
loop {
let mut buffer = vec![0; 2048];
if file.read(&mut buffer).unwrap() == 0 {
break;
}
yield buffer;
}
};
let matcher = Box::new(Simple::from_str(r#"{"users"}[]{"name"}"#).unwrap());
let mut output_generator = StreamsonGenerator::new(input_generator, matcher);
for item in output_generator {
match item {
Ok((path, data)) => {
// Do something with the data
},
Err(err) => {
// Deal with error situation
}
}
}