streamson-generator

Crates.iostreamson-generator
lib.rsstreamson-generator
version7.1.0
sourcesrc
created_at2020-10-04 22:25:39.456628
updated_at2021-05-10 20:20:29.69915
descriptionA library which integrates streamson with generators
homepage
repositoryhttps://github.com/shenek/streamson
max_upload_size
id296162
size10,585
Stepan Henek (shenek)

documentation

README

docs.rs

Streamson generator

A library which integrates streamson with rust generators.

Examples

Use file for input generator

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
		}
	}
}
Commit count: 214

cargo fmt