3 unstable releases

0.2.1 Mar 12, 2020
0.2.0 Jan 18, 2020
0.1.0 May 19, 2019

#5 in #secure-scuttlebutt

AGPL-3.0

38KB
948 lines

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);
};

Dependencies

~1.1–1.8MB
~35K SLoC