#json #generator #json-stream #data-stream #streamson #memory

nightly streamson-generator

A library which integrates streamson with generators

11 stable releases

7.1.0 May 10, 2021
7.0.1 Apr 15, 2021
6.3.1 Dec 8, 2020
6.2.0 Nov 12, 2020
5.0.2 Oct 10, 2020

#326 in FFI

Download history 75/week @ 2024-07-25

75 downloads per month

MIT license

245KB
5.5K SLoC

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
		}
	}
}

lib.rs:

Library which integrates streamson-lib with rust generators

Dependencies