#codec #encoder #serialization #decoder #async-io #byte #protocols

bytecodec

A tiny framework for implementing encoders/decoders of byte-oriented protocols

45 releases

0.4.15 Jul 22, 2021
0.4.13 Jan 6, 2020
0.4.12 Oct 3, 2019
0.4.11 Sep 10, 2018
0.4.6 Jul 30, 2018

#248 in Encoding

Download history 22153/week @ 2024-07-24 16924/week @ 2024-07-31 21002/week @ 2024-08-07 16024/week @ 2024-08-14 16942/week @ 2024-08-21 17257/week @ 2024-08-28 17985/week @ 2024-09-04 15874/week @ 2024-09-11 14325/week @ 2024-09-18 16981/week @ 2024-09-25 17074/week @ 2024-10-02 20169/week @ 2024-10-09 18362/week @ 2024-10-16 16618/week @ 2024-10-23 15333/week @ 2024-10-30 10811/week @ 2024-11-06

64,816 downloads per month
Used in 44 crates (38 directly)

MIT license

210KB
4K SLoC

bytecodec

bytecodec Documentation Actions Status Coverage Status License: MIT

A tiny Rust framework for implementing encoders/decoders of byte-oriented protocols.

Documentation

Features

  • Suited for byte-oriented protocols
  • Incremental encoding/decoding:
    • Encode and Decode traits support incremental encoding and decoding
    • The number of bytes consumed in an execution of encode/decode methods can be completely controlled by the caller
    • This property makes it easy to implement, for example, multi-stream multiplexing, transmittin rate control and asynchronous I/O
  • Composable:
    • By combining multiple encoders (or decoders), it is easy to build a more complex encoder (or decoder)
    • See the examples of EncodeExt and DecodeExt traits
  • Reduced number of memory copies:
    • In design, only two memory copies are required
    • Considering in the decode process, one is the copy from the actual stream (e.g., TCP socket) to the decoding buffer, the other one is the copy to construct the item from the buffer.
  • Supports some serde implemention crates:
    • Currently serde_json and bincode are supported (as optional featuers)
    • See json_codec and bincode_codec modules
  • Easily adapt to synchronous I/O, asynchronous I/O, UDP, etc
  • Trackable errors:
    • By using trackable crate, the location where an error occurred can be easily specified
    • See EncodeExt::map_err and DecodeExt::map_err methods

Dependencies

~1.4–7.5MB
~64K SLoC