Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ssz/src/decode/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ use std::sync::Arc;
macro_rules! impl_decodable_for_uint {
($type: ident, $bit_size: expr) => {
impl Decode for $type {
#[inline(always)]
fn is_ssz_fixed_len() -> bool {
true
}

#[inline(always)]
fn ssz_fixed_len() -> usize {
$bit_size / 8
}

#[inline(always)]
fn from_ssz_bytes(bytes: &[u8]) -> Result<Self, DecodeError> {
let len = bytes.len();
let expected = <Self as Decode>::ssz_fixed_len();
Expand Down
4 changes: 4 additions & 0 deletions ssz/src/encode/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,22 @@ use std::sync::Arc;
macro_rules! impl_encodable_for_uint {
($type: ident, $bit_size: expr) => {
impl Encode for $type {
#[inline(always)]
fn is_ssz_fixed_len() -> bool {
true
}

#[inline(always)]
fn ssz_fixed_len() -> usize {
$bit_size / 8
}

#[inline(always)]
fn ssz_bytes_len(&self) -> usize {
$bit_size / 8
}

#[inline(always)]
fn ssz_append(&self, buf: &mut Vec<u8>) {
buf.extend_from_slice(&self.to_le_bytes());
}
Expand Down
Loading