A Rust crate that adds serde support for the Bin_prot serialization format

Bin_prot serialization format

Serde Bin_prot

A Rust crate that adds serde support for the Bin_prot serialization format

IMPORTANT: This is a work in progress. There is not currently support for all types or full test coverage.

Usage

Following Serde convention this crate exposes a from_reader and to_writer function to serialize/deserialize bin_prot encoded streams of bytes.

This works with any Serde supported data type or any custom type annotated with #[derive(Serialize, Deserialize)].

Example:

use serde_bin_prot::{from_reader, to_writer};

fn main() {
  let val: Vec<i64> = vec![20, -22, 38];

  # Example write into a vec of bytes
  let mut output = Vec::<u8>::new();
  to_writer(&mut output, &val).unwrap();

  # Read back into a typed value
  let de_val: Vec<i64> = from_reader(output.as_slice()).unwrap();
  
  assert!(val == de_val)
}

Testing

All tests can be run through cargo

cargo test

Licence

Distributed under the Apache-2.0 License. See LICENSE for more information.

Contact

Willem Olding

Issues

Collection of the latest Issues

willemolding

willemolding

0

This crate is destined to run in a WASM environment and being able to build without the standard library will be a significant benefit.

  • Ensure that this crate can build with the #![no_std] attribute and this allows it to build without the standard library and drop features where required
willemolding

willemolding

0

The canonical implementation of Bin_prot in OCaml comes with a comprehensive test suite. Ideally we want to show that this implementation passes every one of these tests.

There are two ways we can go about this:

  • A systematic way to migrate the tests from OCaml to Rust and run natively
  • A way to call into an OCaml runtime and exchange bytes produced by the existing test cases

Need to make a decision which of these approaches to go with

willemolding

willemolding

help wanted
1

In the bin_prot specification, each enum variant is assigned an index between 0 and n-1. When serializing an enum of the type, the variant index is written first followed by any data tied to the variant.

The variant index is to be written as 1 or 2 bytes depending on how many variants, n, there are: n <= 256 -> write out lower 8 bits of n (1 byte) n <= 65536 -> write out lower 16 bits of n (2 bytes)

In Rust I can't figure out a way to know during serialization or deserialization how many variants there are and thus which encoding to use. Currently this crate assumes only <=256 variants and writes a single byte.

Encoding or decoding enums with more than this will result in an invalid encoding.

Information - Updated May 28, 2022

Stars: 5
Forks: 1
Issues: 8

CDRS is looking for maintainers

CDRS is Apache Cassandra driver written in pure Rust

CDRS is looking for maintainers
Http

371

A push parser for the HTTP 1

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2

A push parser for the HTTP 1

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

This library is released under the MIT License and the Apache v2 License (see License)

The arkworks ecosystem consist of Rust libraries for designing and working with zero knowledge succinct...

Say Hello To DataBend The Open Source Cloud Warehouse for Everyone

Databend is inspired by apache-arrow and allows you to scale your cloud warehousing, using off the shelf open source stacks & the ultra fast processing speeds you come to expect from say Bigquery

Say Hello To DataBend The Open Source Cloud Warehouse for Everyone

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀

This project is duel-licensed under both the Apache licenses, so feel free to use either at your discretion

Bespoke protocol and high-level implementation of Non-fungible token (NFT) technology 🚀
Facebook Instagram Twitter GitHub Dribbble
Privacy