[][src]Crate tokio_serde

This crate provides the utilities needed to easily implement a Tokio transport using serde for serialization and deserialization of frame values.

Introduction

This crate provides transport combinators that transform a stream of frames encoded as bytes into a stream of frame values. It is expected that the framing happens at another layer. One option is to use a length delimited framing transport.

The crate provides two traits that must be implemented: Serializer and Deserializer. Implementations of these traits are then passed to Framed along with the upstream Stream or Sink that handles the byte encoded frames.

By doing this, a transformation pipeline is built. For reading, it looks something like this:

  • tokio_serde::Framed
  • tokio_util::codec::FramedRead
  • tokio::net::TcpStream

The write half looks like:

  • tokio_serde::Framed
  • tokio_util::codec::FramedWrite
  • tokio::net::TcpStream

Examples

For an example, see how JSON support is implemented:

Modules

formats

Structs

Framed

Adapts a transport to a value sink by serializing the values and to a stream of values by deserializing them.

Traits

Deserializer

Deserializes a value from a source buffer

Serializer

Serializes a value into a destination buffer

Type Definitions

SymmetricallyFramed