ashleygwilliams / changes-stream-rust

a changes stream for couchdb style APIs - written in Rust

Home Page:https://ashleygwilliams.github.io/changes-stream-rust/changes_stream/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

changes-stream-rust

travis badge

an implementation of changes-stream in Rust.

this code reads in a readable stream from an endpoint and returns each chunk in JSON.

this code works off of the tokio branch of hyper to take advantage of new Rust Futures.

changes-stream-rust only works on nightly because it uses serde.

usage

in your Cargo.toml:

[dependencies]
changes-stream = { git = "https://github.com/ashleygwilliams/changes-stream-rust.git" }

from examples/follower.rs:

extern crate changes_stream;
extern crate futures;

use std::io;
use std::io::Write;

use changes_stream::ChangesStream;

fn main() {
    let url = "https://replicate.npmjs.com/_changes".to_string();
    let mut changes = ChangesStream::new(url);

    changes.on(|change| {
        io::stdout().write_all(&change).unwrap();
    });

    changes.run();
}

About

a changes stream for couchdb style APIs - written in Rust

https://ashleygwilliams.github.io/changes-stream-rust/changes_stream/index.html

License:MIT License


Languages

Language:Rust 100.0%