wasm: self-review edits

This commit is contained in:
Brian Carroll 2022-05-25 22:53:44 +01:00
parent 4300ef8b47
commit 11c1c92cc1
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7
3 changed files with 17 additions and 22 deletions

View file

@ -13,12 +13,6 @@ pub struct ParseError {
pub message: String,
}
/// Skip over serialized bytes for a type
/// This may, or may not, require looking at the byte values
pub trait SkipBytes: Sized {
fn skip_bytes(bytes: &[u8], cursor: &mut usize) -> Result<(), ParseError>;
}
/// Decode an unsigned 32-bit integer from the provided buffer in LEB-128 format
/// Return the integer itself and the offset after it ends
fn decode_u32(bytes: &[u8]) -> Result<(u32, usize), ()> {
@ -64,6 +58,12 @@ impl<'a> Parse<&'a Bump> for &'a str {
}
}
/// Skip over serialized bytes for a type
/// This may, or may not, require looking at the byte values
pub trait SkipBytes: Sized {
fn skip_bytes(bytes: &[u8], cursor: &mut usize) -> Result<(), ParseError>;
}
impl SkipBytes for u32 {
fn skip_bytes(bytes: &[u8], cursor: &mut usize) -> Result<(), ParseError> {
const MAX_LEN: usize = 5;