Crate tokio_serde_cbor
source · [−]Expand description
This crate integrates CBOR into Tokio.
This crate provides a codec for framing information as CBOR encoded messages. It allows
encoding and decoding arbitrary serde ready types. It can be used by
plugging the codec into the connection’s framed
method to get stream and sink of the desired
items.
The encoded and decoded items are independent (you may want to encode references and decode
owned data, or the protocol might be asymetric). If you want just one direction, you can use
Decoder
or Encoder
. If you want both, you
better use Codec
.
Note that this is useful if the CBOR itself defines the frames. If the messages are delimited
in some other way (eg. length-prefix encoding) and CBOR is only the payload, you’d use a codec
for the other framing and use .map
on the received stream and sink to convert the messages.