Skip to content

elwerene/changes-stream-rust

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

changes-stream-rust

travis badge

an implementation of changes-stream in Rust.

this code reads in a readable stream from an endpoint, parses each line and returns CouchDB changes events as defined in src/event.rs.

usage

in your Cargo.toml:

[dependencies]
changes-stream = "0.2"

from examples/follower.rs:

use changes_stream::{ChangesStream, Event};
use futures_util::stream::StreamExt;

#[tokio::main]
async fn main() {
    let url = "https://replicate.npmjs.com/_changes".to_string();
    let mut changes = ChangesStream::new(url).await.unwrap();
    while let Some(event) = changes.next().await {
        match event {
            Ok(Event::Change(change)) => println!("Change ({}): {}", change.seq, change.id),
            Ok(Event::Finished(finished)) => println!("Finished: {}", finished.last_seq),
            Err(err) => println!("Error: {:?}", err),
        }
    }
}

About

a changes stream for couchdb style APIs - written in Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%