#json #tokio

streamson-tokio

Tokio and streamson integration library

12 releases (6 major breaking)

new 6.0.0 Oct 12, 2020
5.0.2 Oct 10, 2020
4.1.0 Aug 29, 2020
4.0.0 Jul 28, 2020
0.2.0 May 29, 2020

#155 in Parser tooling

Download history 30/week @ 2020-06-25 23/week @ 2020-07-02 14/week @ 2020-07-09 22/week @ 2020-07-16 26/week @ 2020-07-23 13/week @ 2020-07-30 7/week @ 2020-08-06 15/week @ 2020-08-13 9/week @ 2020-08-20 18/week @ 2020-08-27 24/week @ 2020-09-03 2/week @ 2020-09-24 13/week @ 2020-10-01 36/week @ 2020-10-08

58 downloads per month

MIT license

145KB
3K SLoC

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
 }

lib.rs:

Library which integrates streamson-lib into tokio

Dependencies

~2MB
~31K SLoC