Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 1.22 KB

README.md

File metadata and controls

49 lines (31 loc) · 1.22 KB

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();
}