Skip to main content

Module codec

Module codec 

Source
Expand description

Utility methods to encode or decode wire protocol messages in Postcard format with message framing using 4 bytes frame length prefixes.

§Example

Encoding for string “hello” (10 bytes):

          Postcard varint prefix
             |
Frame Length |
 (4 bytes)   |    "hello" string (5 bytes)
    |        |          |
[----------] | [-h----e----l----l----o-]
[0, 0, 0, 6, 5, 104, 101, 108, 108, 111]
============ ===========================
   PREFIX              MESSAGE

Structs§

Codec
Implementation of the tokio codec traits to encode- and decode length-prefixed postcard data as a framed stream.

Enums§

CodecError
Errors which can occur while decoding or encoding streams of postcard bytes.

Functions§

into_codec_sink
Returns a writer for your wire-protocol messages, automatically encoding it as a framed byte-stream.
into_codec_stream
Returns a reader for your wire-protocol messages, automatically decoding byte-streams and handling the framing.