Last active
May 16, 2017 16:47
-
-
Save yoshuawuyts/1b59434bce5c66f8edc159e7d3df3eff to your computer and use it in GitHub Desktop.
Rough rust translation of the https://github.com/ssbc/secure-scuttlebutt example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate ssb_keys; | |
extern crate ssb; | |
extern crate mio; | |
#[macro_use] | |
extern crate pull; | |
const pathToSecret: String = "/tmp/ssb1-secret"; | |
const pathToDB: String = "/tmp/ssb1/"; | |
struct Msg { | |
name: &str, | |
text: &str, | |
} | |
fn main () { | |
let ev = mio::EventLoop::new(); | |
let keys = ssb_keys::generate(); | |
let ssb = ssb::create(pathToDB); | |
let feed = ssb.createFeed(ev, keys); | |
// send a message | |
let msg = Msg { name: "post", text: "My first post!" }; | |
feed.add(msg, |res: ssb::FeedResponse| { | |
println!("{}", res.msg); | |
println!("{}", res.hash); | |
}); | |
// stream all messages for all keypairs | |
pull!(ssb::createFeedStream(ev), pull::collect(|res: Option<(), i32>| { | |
println!("{}", res); | |
})); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment