Crates.io | spread |
lib.rs | spread |
version | 0.0.1 |
source | src |
created_at | 2014-12-13 20:46:35.895988 |
updated_at | 2015-12-11 23:56:18.321051 |
description | A Rust client library for the Spread toolkit |
homepage | |
repository | https://github.com/evnm/spread.rs |
max_upload_size | |
id | 544 |
size | 23,148 |
A Rust client library for the Spread toolkit.
Spread is a toolkit that provides a high performance messaging service that is resilient to faults across external or internal networks. More info at spread.org.
This library is a simplified implementation of the Spread client protocol. It supports the six basic calls of the Spread API:
No further functionality is currently implemented (e.g. no message types beyond simple reliable multicast, quality of service, connection prioritization, non-null authentication).
spread-rs
has a single external library dependency upon
rust-encoding.
To build:
$ cargo build
To test:
$ cargo test
To generate documentation:
$ cargo doc
Connect to a Spread daemon running locally on port 4803:
extern crate spread;
use std::io::net::ip::SocketAddr;
let socket_addr =
from_str::<SocketAddr>("127.0.0.1:4803").expect("malformed address");
let client = spread::connect(socket_addr, "test_user", false)
.ok().expect("failed to create client");
Join a group and multicast a message:
client.join("foo_group".as_slice());
client.multicast(["foo_group"], "hello".as_bytes());
Block on receipt of a message, print the contents, and then leave and disconnect:
let msg = client.receive().ok().expect("receive failed");
println!("sender: {}", msg.sender);
println!("groups: {}", msg.groups);
println!("data: {}", msg.data);
client.leave("foo_group".as_slice());
client.disconnect();