Crates.io | ssb-packetstream |
lib.rs | ssb-packetstream |
version | 0.2.1 |
source | src |
created_at | 2019-05-19 19:02:47.511814 |
updated_at | 2020-03-12 06:36:38.086947 |
description | Secure Scuttlebutt packet stream protocol |
homepage | |
repository | https://github.com/sunrise-choir/ssb-packetstream |
max_upload_size | |
id | 135314 |
size | 71,644 |
An implementation of the packet-stream protocol used by Secure Scuttlebutt.
use futures::prelude::{SinkExt, StreamExt};
use packetstream::*;
let p = Packet {
is_stream: IsStream::Yes,
is_end: IsEnd::No,
body_type: BodyType::Binary,
id: 12345,
body: vec![1,2,3,4,5]
};
let (writer, reader) = async_ringbuffer::ring_buffer(64);
let mut sink = PacketSink::new(writer);
let mut stream = PacketStream::new(reader);
async {
sink.send(p).await;
let r = stream.next().await.unwrap().unwrap();
assert_eq!(&r.body, &[1,2,3,4,5]);
assert_eq!(r.id, 12345);
};