Implement ssz::Decodable for u8

This commit is contained in:
Paul Hauner 2018-09-23 17:22:27 +10:00
parent 3968aaa0e0
commit 0b661c5b11
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C

View File

@ -36,6 +36,18 @@ impl_decodable_for_uint!(u32, 32);
impl_decodable_for_uint!(u64, 64);
impl_decodable_for_uint!(usize, 64);
impl Decodable for u8 {
fn ssz_decode(bytes: &[u8], index: usize)
-> Result<(Self, usize), DecodeError>
{
if index >= bytes.len() {
Err(DecodeError::TooShort)
} else {
Ok((bytes[index], index + 1))
}
}
}
impl Decodable for H256 {
fn ssz_decode(bytes: &[u8], index: usize)
-> Result<(Self, usize), DecodeError>