streamson-tokio

Crates.iostreamson-tokio
lib.rsstreamson-tokio
version7.1.0
sourcesrc
created_at2020-05-29 22:26:27.039596
updated_at2021-05-10 20:21:23.287364
descriptionTokio and streamson integration library
homepage
repositoryhttps://github.com/shenek/streamson
max_upload_size
id247532
size10,115
Stepan Henek (shenek)

documentation

README

docs.rs

Streamson tokio

A library which integrates streamson with tokio. So that you can easily process JSONs using asynchronous rust.

Examples

Reading a large file

 use std::io;
 use streamson_lib::{error, matcher};
 use streamson_tokio::decoder::Extractor;
 use tokio::{fs, stream::StreamExt};
 use tokio_util::codec::FramedRead;

 let mut file = fs::File::open("/tmp/large.json").await?;
 let matcher = matcher::Combinator::new(matcher::Simple::new(r#"{"users"}[]"#).unwrap())
     | matcher::Combinator::new(matcher::Simple::new(r#"{"groups"}[]"#).unwrap());
 let extractor = Extractor::new(matcher);
 let mut output = FramedRead::new(file, extractor);
 while let Some(item) = output.next().await {
     let (path, data) = item?;
     // Do something with extracted data
 }
Commit count: 214

cargo fmt