#type #async-channel #session #channel #protocols #async #serializer-deserializer

dialectic-tokio-serde

A backend builder for the Dialectic crate using Serde serialization over Tokio transport

1 unstable release

0.1.0 Apr 1, 2021

#36 in #async-channel

Download history 4/week @ 2024-02-14 15/week @ 2024-02-21 11/week @ 2024-02-28 5/week @ 2024-03-06 6/week @ 2024-03-13 4/week @ 2024-03-20 21/week @ 2024-03-27 27/week @ 2024-04-03

52 downloads per month
Used in 3 crates

MIT license

170KB
2K SLoC

Rust license: MIT crates.io docs.rs documentation

The dialectic-tokio-serde crate provides Dialectic Transmitter and Receiver types which are capable of sending/receiving any serde-Serialize/Deserialize type. These are generic over their transport, and require three additional parameters to function:

  • Async-capable writer/reader types which implement the Tokio AsyncWrite and AsyncRead traits.
  • A Tokio codec, for encoding and decoding frames which are written to/read from the asynchronous writer/reader.
  • A dialectic_tokio_serde::Serializer/Deserializer for converting the sent/received types to/from the wire format. PLEASE NOTE! These are not the serde Serializer/Deserializer traits but rather similar traits which also define the possible output/input types of the Serializer/Deserializer.

Tokio/serde backends for Dialectic

Currently, two formats are implemented as sister crates:

  • The dialectic-tokio-serde-bincode crate, which when provided an AsyncWrite/AsyncRead transport enables serialization to/from the bincode format and using the tokio_util LengthDelimitedCodec for a wire encoding.
  • The dialectic-tokio-serde-json crate, which when provided an AsyncWrite/AsyncRead transport enables serialization to/from the JSON format and using the tokio_util LinesCodec for a wire encoding.

Dependencies

~6–14MB
~148K SLoC