6 releases (3 breaking)

0.4.0 Nov 23, 2021
0.3.0 Aug 24, 2021
0.2.0 Jul 29, 2021
0.1.2 Jul 19, 2019

#6 in #ssz

Download history 239/week @ 2024-07-22 319/week @ 2024-07-29 141/week @ 2024-08-05 56/week @ 2024-08-12 41/week @ 2024-08-19 106/week @ 2024-08-26 84/week @ 2024-09-02 174/week @ 2024-09-09 53/week @ 2024-09-16 127/week @ 2024-09-23 48/week @ 2024-09-30 40/week @ 2024-10-07 68/week @ 2024-10-14 9/week @ 2024-10-21 92/week @ 2024-10-28 28/week @ 2024-11-04

199 downloads per month
Used in 5 crates

Apache-2.0

62KB
1.5K SLoC

simpleserialize (ssz)


lib.rs:

Provides encoding (serialization) and decoding (deserialization) in the SimpleSerialize (SSZ) format designed for use in Ethereum 2.0.

Adheres to the Ethereum 2.0 SSZ specification at v0.12.1.

Example

use ssz_derive::{Encode, Decode};
use ssz::{Decode, Encode};

#[derive(PartialEq, Debug, Encode, Decode)]
struct Foo {
    a: u64,
    b: Vec<u16>,
}

fn ssz_encode_decode_example() {
    let foo = Foo {
        a: 42,
        b: vec![1, 3, 3, 7]
    };

    let ssz_bytes: Vec<u8> = foo.as_ssz_bytes();

    let decoded_foo = Foo::from_ssz_bytes(&ssz_bytes).unwrap();

    assert_eq!(foo, decoded_foo);
}

See examples/ for manual implementations of the Encode and Decode traits.

Dependencies

~465KB