#protocol #network #bin-prot

binprot

Rust implementation of the bin_prot protocol

7 releases

0.1.7 Jan 24, 2022
0.1.6 Dec 20, 2021
0.1.3 Nov 19, 2021
0.1.0 Jul 17, 2021

#406 in Network programming

Download history 37/week @ 2022-01-24 16/week @ 2022-01-31 8/week @ 2022-02-07 11/week @ 2022-02-14 3/week @ 2022-02-21 10/week @ 2022-02-28 17/week @ 2022-03-07 50/week @ 2022-03-14 24/week @ 2022-03-21 7/week @ 2022-03-28 14/week @ 2022-04-04 4/week @ 2022-04-11 5/week @ 2022-04-18 18/week @ 2022-04-25 59/week @ 2022-05-02 10/week @ 2022-05-09

93 downloads per month
Used in timens

MIT/Apache

37KB
988 lines

binprot-rs

Bin_prot binary protocols in Rust

Build Status Latest version Documentation License

This crates provides bin_prot serialization and tries to be compatible with the OCaml version for similar types.

The examples directory includes a tiny RPC implementation compatible with OCaml Async_rpc. The Query message is defined as follows in OCaml as can be found in the implementation.

module Query = struct
  type 'a needs_length =
    { tag     : Rpc_tag.t
    ; version : int
    ; id      : Query_id.t
    ; data    : 'a
    }
  [@@deriving bin_io]
  type 'a t = 'a needs_length [@@deriving bin_read]
end

The equivalent type using Rust would be:

#[derive(BinProtRead, BinProtWrite)]
struct Query<T> {
    rpc_tag: String,
    version: i64,
    id: i64,
    data: binprot::WithLen<T>,
}

This does not use serde (see serde-binprot) but instead implements the derive macro independently so as to provide better control on serialization. In particular polymorphic variants can be supported thanks to this.

Dependencies

~0.3–1.4MB
~27K SLoC