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

#7 in #ssz

Download history 305/week @ 2024-03-25 378/week @ 2024-04-01 155/week @ 2024-04-08 213/week @ 2024-04-15 150/week @ 2024-04-22 357/week @ 2024-04-29 425/week @ 2024-05-06 217/week @ 2024-05-13 185/week @ 2024-05-20 88/week @ 2024-05-27 120/week @ 2024-06-03 206/week @ 2024-06-10 365/week @ 2024-06-17 229/week @ 2024-06-24 196/week @ 2024-07-01 226/week @ 2024-07-08

1,058 downloads per month
Used in 6 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

~470KB