Add support for SSZ union type via Option

This commit is contained in:
Paul Hauner
2019-06-04 12:03:54 +10:00
parent 7005234fd1
commit 7a2ab2e9aa
5 changed files with 141 additions and 1 deletions

View File

@@ -218,6 +218,12 @@ impl<'a> SszDecoder<'a> {
}
}
/// Reads a `BYTES_PER_LENGTH_OFFSET`-byte union index from `bytes`, where `bytes.len() >=
/// BYTES_PER_LENGTH_OFFSET`.
pub fn read_union_index(bytes: &[u8]) -> Result<usize, DecodeError> {
read_offset(bytes)
}
/// Reads a `BYTES_PER_LENGTH_OFFSET`-byte length from `bytes`, where `bytes.len() >=
/// BYTES_PER_LENGTH_OFFSET`.
fn read_offset(bytes: &[u8]) -> Result<usize, DecodeError> {