ssb-packetstream

Crates.iossb-packetstream
lib.rsssb-packetstream
version0.2.1
sourcesrc
created_at2019-05-19 19:02:47.511814
updated_at2020-03-12 06:36:38.086947
descriptionSecure Scuttlebutt packet stream protocol
homepage
repositoryhttps://github.com/sunrise-choir/ssb-packetstream
max_upload_size
id135314
size71,644
all (github:sunrise-choir:all)

documentation

https://docs.rs/ssb-packetstream/

README

Packet Stream

Documentation Build Status

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);
};
Commit count: 46

cargo fmt