1 unstable release
0.4.0 | Dec 6, 2021 |
---|
#11 in #ssz
57KB
1.5K
SLoC
simpleserialize-bigendian (sszb)
Same as ssz but with BigEndian notation.
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 but endian is switched SSZ specification at v0.12.1.
Example
use sszb_derive::{Encode, Decode};
use sszb::{Decode, Encode};
#[derive(PartialEq, Debug, Encode, Decode)]
struct Foo {
a: u64,
b: Vec<u16>,
}
fn sszb_encode_decode_example() {
let foo = Foo {
a: 42,
b: vec![1, 3, 3, 7]
};
let sszb_bytes: Vec<u8> = foo.as_sszb_bytes();
let decoded_foo = Foo::from_sszb_bytes(&sszb_bytes).unwrap();
assert_eq!(foo, decoded_foo);
}
See examples/
for manual implementations of the Encode
and Decode
traits.
Dependencies
~2.5MB
~52K SLoC