serde_token

Crates.ioserde_token
lib.rsserde_token
version0.0.2
sourcesrc
created_at2019-06-24 06:09:55.145968
updated_at2019-06-24 06:20:53.35646
descriptionUtility for transcoding a Serde deserializer into a sink of tokens.
homepage
repositoryhttps://github.com/sunny-g/serde_token
max_upload_size
id143133
size21,945
Sunny Gonnabathula (sunny-g)

documentation

README

serde_token

Crates.io Documentation MIT license

serde_token provides a utility for transcoding a Serde deserializer into a sink of Tokens.

Installation

Install from Crates.io:

[dependencies]
serde_token = "0.0.2"

Usage

use futures::{unsync::mpsc::unbounded, Future, Sink, Stream};
use serde_json::Deserializer;
use serde_token::{tokenize, Token};

let mut de = Deserializer::from_str(r#" [ {"a":false}, "hello", 3 ] "#);
let (token_sink, token_stream) = unbounded::<Token>();

tokenize(&mut de, token_sink).unwrap();

let expected = token_stream.collect().wait().unwrap();
assert_eq!(expected, vec![
    Token::Seq { len: None },
    Token::Map { len: None },
    Token::Str("a"),
    Token::Bool(false),
    Token::MapEnd,
    Token::Str("hello"),
    Token::U64(3),
    Token::SeqEnd,
])

TODO

  • look into handling Sink sending better (i.e. support back-pressure)

Changelog

Version Change Summary
v0.0.2 adds README
v0.0.1 initial release

Contributing

  1. Fork it https://github.com/your_username/serde_token/fork
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Maintainers

License

MIT

Commit count: 8

cargo fmt