#postcard #transport #tokio #stream #tokio-serde

tokio-serde-postcard

tokio-serde transport based on postcard format

1 unstable release

0.1.0 Dec 1, 2023

#1836 in Encoding

Download history 172/week @ 2024-07-09 88/week @ 2024-07-16 61/week @ 2024-07-23 91/week @ 2024-07-30 71/week @ 2024-08-06 58/week @ 2024-08-13 130/week @ 2024-08-20 182/week @ 2024-08-27 115/week @ 2024-09-03 135/week @ 2024-09-10 159/week @ 2024-09-17 363/week @ 2024-09-24 155/week @ 2024-10-01 255/week @ 2024-10-08 132/week @ 2024-10-15 151/week @ 2024-10-22

734 downloads per month

Apache-2.0

7KB

tokio-serde-postcard

tokio-serde transport based on postcard format.

Usage

Adding dependency:

[dependencies]
tokio-serde-postcard = "0.1"

Transport initialization is the same as the built-in tokio_serde serializers:

fn framed_tcp_stream<Item, SinkItem>(
    stream: TcpStream,
) -> tokio_serde::Framed<
    tokio_util::codec::Framed<TcpStream, LengthDelimitedCodec>,
    Item,
    SinkItem,
    tokio_serde_postcard::Postcard<Item, SinkItem>,
> {
    // First wrap the stream with a basic length-delimited codec.
    let transport =
        tokio_util::codec::Framed::new(stream, tokio_util::codec::LengthDelimitedCodec::default());

    // Then wrap the transport with `tokio_serde`.
    tokio_serde::Framed::new(transport, tokio_serde_postcard::Postcard::default())
}

License

Apache 2.0

Dependencies

~0.8–1.5MB
~30K SLoC