#canon #serialisation #no-std #ffi #database

nightly no-std canonical

A serialization library built for no_std environments where you want to deal with recursive datastructures

17 releases (6 breaking)

new 0.6.5 Jun 8, 2021
0.6.3 May 27, 2021
0.6.0 Mar 30, 2021
0.4.4 Dec 29, 2020
0.4.2 Nov 12, 2020

#76 in Database implementations

Download history 153/week @ 2021-02-23 38/week @ 2021-03-02 86/week @ 2021-03-09 106/week @ 2021-03-16 53/week @ 2021-03-23 95/week @ 2021-03-30 116/week @ 2021-04-06 96/week @ 2021-04-13 158/week @ 2021-04-20 289/week @ 2021-04-27 218/week @ 2021-05-04 142/week @ 2021-05-11 121/week @ 2021-05-18 209/week @ 2021-05-25 75/week @ 2021-06-01 178/week @ 2021-06-08

584 downloads per month
Used in 19 crates (18 directly)

MPL-2.0 license

32KB
786 lines

Canonical

Build Status Repository Documentation

Canonical is a specialized serialization library built for merkle trees and suitable for wasm environments.

Its main component is the Canon trait, which specifies how the type is encoded to/read from bytes.

This allows you, for example, to easily pass complex sets containing millions of elements between different wasm modules.

identifiers

Each value of a type implementing the Canon trait has a 1:1 relation to an Id.

let a = 42;

let id = Id::new(&a);

assert_eq!(id.reify().expect("read back"), a);

The Repr<T> is a smart-pointer type that either owns the value, contains a cryptographic hash of the value, or both. This allows you to construct recursive data types, that can also effeciently be stored and accessed as merkle trees.

canonical_derive

In order not to have to write all this byte-counting code by hand, canonical includes a derive-macro to implement them for you.

#[derive(Canon, PartialEq, Debug)]
struct A2 {
    a: u8,
    b: u8,
}

canonical_fuzz

A simple fuzzer built on top of the arbitrary crate. Allows you to fuzz the canon encoding for types, helpful if you choose to implement custom encodings.

The fuzzer also checks that the reported length of the value is correct with what is being written.

Dependencies

~400KB