#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

#1853 in Encoding

Download history 70/week @ 2024-07-24 84/week @ 2024-07-31 80/week @ 2024-08-07 54/week @ 2024-08-14 147/week @ 2024-08-21 176/week @ 2024-08-28 98/week @ 2024-09-04 156/week @ 2024-09-11 175/week @ 2024-09-18 380/week @ 2024-09-25 178/week @ 2024-10-02 183/week @ 2024-10-09 139/week @ 2024-10-16 184/week @ 2024-10-23 156/week @ 2024-10-30 87/week @ 2024-11-06

583 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.4MB
~29K SLoC