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

19 lines
462 B
Rust
Raw Normal View History

mod decode;
mod encode;
pub use decode::{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()
}