lighthouse/eth2/utils/ssz/src/lib.rs

22 lines
526 B
Rust
Raw Normal View History

mod decode;
mod encode;
2019-05-13 02:33:59 +00:00
mod macros;
pub use decode::{
impls::decode_list_of_variable_length_items, Decodable, DecodeError, SszDecoderBuilder,
};
2019-05-05 23:26:58 +00:00
pub use encode::{Encodable, SszEncoder};
pub const BYTES_PER_LENGTH_OFFSET: usize = 4;
pub const MAX_LENGTH_VALUE: usize = (1 << (BYTES_PER_LENGTH_OFFSET * 8)) - 1;
/// Convenience function to SSZ encode an object supporting ssz::Encode.
2019-05-05 23:26:58 +00:00
///
/// Equivalent to `val.as_ssz_bytes()`.
pub fn ssz_encode<T>(val: &T) -> Vec<u8>
where
T: Encodable,
{
2019-05-05 23:26:58 +00:00
val.as_ssz_bytes()
}