make ssz crate wasm compatible

This commit is contained in:
Matt Garnett 2019-06-22 14:34:29 -04:00
parent 2a50550b87
commit 87e681c617
2 changed files with 7 additions and 0 deletions

View File

@ -34,6 +34,11 @@ impl_decodable_for_uint!(u8, 8);
impl_decodable_for_uint!(u16, 16);
impl_decodable_for_uint!(u32, 32);
impl_decodable_for_uint!(u64, 64);
#[cfg(target_pointer_width = "32")]
impl_decodable_for_uint!(usize, 32);
#[cfg(target_pointer_width = "64")]
impl_decodable_for_uint!(usize, 64);
impl Decode for bool {

View File

@ -46,6 +46,8 @@ pub use encode::{Encode, SszEncoder};
/// The number of bytes used to represent an offset.
pub const BYTES_PER_LENGTH_OFFSET: usize = 4;
/// The maximum value that can be represented using `BYTES_PER_LENGTH_OFFSET`.
// allows overflow on 32-bit target
#[allow(const_err)]
pub const MAX_LENGTH_VALUE: usize = (1 << (BYTES_PER_LENGTH_OFFSET * 8)) - 1;
/// Convenience function to SSZ encode an object supporting ssz::Encode.