Struct wasmtime_environ::wasm::wasmparser::BinaryReader [−][src]
pub struct BinaryReader<'a> { /* fields omitted */ }
Expand description
A binary reader of the WebAssembly structures and types.
Implementations
impl<'a> BinaryReader<'a>
[src]
impl<'a> BinaryReader<'a>
[src]pub fn new(data: &[u8]) -> BinaryReader<'_>
[src]
pub fn new(data: &[u8]) -> BinaryReader<'_>
[src]Constructs BinaryReader
type.
Examples
let fn_body = &vec![0x41, 0x00, 0x10, 0x00, 0x0B]; let mut reader = wasmparser::BinaryReader::new(fn_body); while !reader.eof() { let op = reader.read_operator(); println!("{:?}", op) }
pub fn new_with_offset(data: &[u8], original_offset: usize) -> BinaryReader<'_>
[src]
pub fn new_with_offset(data: &[u8], original_offset: usize) -> BinaryReader<'_>
[src]Constructs a BinaryReader
with an explicit starting offset.
pub fn original_position(&self) -> usize
[src]
pub fn read_type(&mut self) -> Result<Type, BinaryReaderError>
[src]
pub fn current_position(&self) -> usize
[src]
pub fn current_position(&self) -> usize
[src]Returns the BinaryReader
’s current position.
pub fn bytes_remaining(&self) -> usize
[src]
pub fn bytes_remaining(&self) -> usize
[src]Returns the number of bytes remaining in the BinaryReader
.
pub fn read_bytes(&mut self, size: usize) -> Result<&'a [u8], BinaryReaderError>
[src]
pub fn read_bytes(&mut self, size: usize) -> Result<&'a [u8], BinaryReaderError>
[src]Advances the BinaryReader
size
bytes, and returns a slice from the
current position of size
length.
Errors
If size
exceeds the remaining length in BinaryReader
.
pub fn read_u32(&mut self) -> Result<u32, BinaryReaderError>
[src]
pub fn read_u32(&mut self) -> Result<u32, BinaryReaderError>
[src]Advances the BinaryReader
four bytes and returns a u32
.
Errors
If BinaryReader
has less than four bytes remaining.
pub fn read_u64(&mut self) -> Result<u64, BinaryReaderError>
[src]
pub fn read_u64(&mut self) -> Result<u64, BinaryReaderError>
[src]Advances the BinaryReader
eight bytes and returns a u64
.
Errors
If BinaryReader
has less than eight bytes remaining.
pub fn read_u8(&mut self) -> Result<u32, BinaryReaderError>
[src]
pub fn read_u8(&mut self) -> Result<u32, BinaryReaderError>
[src]Advances the BinaryReader
a single byte, and returns the data as
a u32
.
Errors
If BinaryReader
has no bytes remaining.
pub fn read_var_u8(&mut self) -> Result<u32, BinaryReaderError>
[src]
pub fn read_var_u8(&mut self) -> Result<u32, BinaryReaderError>
[src]Advances the BinaryReader
up to two bytes to parse a variable
length integer as a u8
.
Errors
If BinaryReader
has less than one or two bytes remaining, or the
integer is larger than eight bits.
pub fn read_var_u32(&mut self) -> Result<u32, BinaryReaderError>
[src]
pub fn read_var_u32(&mut self) -> Result<u32, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a u32
.
Errors
If BinaryReader
has less than one or up to four bytes remaining, or
the integer is larger than 32 bits.
pub fn read_var_u64(&mut self) -> Result<u64, BinaryReaderError>
[src]
pub fn read_var_u64(&mut self) -> Result<u64, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a u64
.
Errors
If BinaryReader
has less than one or up to eight bytes remaining, or
the integer is larger than 64 bits.
pub fn skip_var_32(&mut self) -> Result<(), BinaryReaderError>
[src]
pub fn skip_var_32(&mut self) -> Result<(), BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes over a variable length 32
bit integer, discarding the result.
Errors
If BinaryReader
has less than one or up to four bytes remaining, or
the integer is larger than 32 bits.
pub fn skip_type(&mut self) -> Result<(), BinaryReaderError>
[src]
pub fn skip_type(&mut self) -> Result<(), BinaryReaderError>
[src]Alias method for BinaryReader::skip_var_u32
.
pub fn skip_bytes(&mut self, len: usize) -> Result<(), BinaryReaderError>
[src]
pub fn skip_bytes(&mut self, len: usize) -> Result<(), BinaryReaderError>
[src]Advances the BinaryReader
len
bytes, skipping the result.
Errors
If BinaryReader
has less than len
bytes remaining.
pub fn skip_string(&mut self) -> Result<(), BinaryReaderError>
[src]
pub fn skip_string(&mut self) -> Result<(), BinaryReaderError>
[src]Advances the BinaryReader
past a WebAssembly string. This method does
not perform any utf-8 validation.
Errors
If BinaryReader
has less than four bytes, the string’s length exceeds
the remaining bytes, or the string length
exceeds limits::MAX_WASM_STRING_SIZE
.
pub fn read_var_i32(&mut self) -> Result<i32, BinaryReaderError>
[src]
pub fn read_var_i32(&mut self) -> Result<i32, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a i32
.
Errors
If BinaryReader
has less than one or up to four bytes remaining, or
the integer is larger than 32 bits.
pub fn read_var_s33(&mut self) -> Result<i64, BinaryReaderError>
[src]
pub fn read_var_s33(&mut self) -> Result<i64, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a signed 33 bit integer, returned as a i64
.
Errors
If BinaryReader
has less than one or up to five bytes remaining, or
the integer is larger than 33 bits.
pub fn read_var_i64(&mut self) -> Result<i64, BinaryReaderError>
[src]
pub fn read_var_i64(&mut self) -> Result<i64, BinaryReaderError>
[src]Advances the BinaryReader
up to eight bytes to parse a variable
length integer as a 64 bit integer, returned as a i64
.
Errors
If BinaryReader
has less than one or up to eight bytes remaining, or
the integer is larger than 64 bits.
pub fn read_f32(&mut self) -> Result<Ieee32, BinaryReaderError>
[src]
pub fn read_f32(&mut self) -> Result<Ieee32, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a 32 bit floating point integer, returned as Ieee32
.
Errors
If BinaryReader
has less than one or up to four bytes remaining, or
the integer is larger than 32 bits.
pub fn read_f64(&mut self) -> Result<Ieee64, BinaryReaderError>
[src]
pub fn read_f64(&mut self) -> Result<Ieee64, BinaryReaderError>
[src]Advances the BinaryReader
up to four bytes to parse a variable
length integer as a 32 bit floating point integer, returned as Ieee32
.
Errors
If BinaryReader
has less than one or up to four bytes remaining, or
the integer is larger than 32 bits.
pub fn read_string(&mut self) -> Result<&'a str, BinaryReaderError>
[src]
pub fn read_string(&mut self) -> Result<&'a str, BinaryReaderError>
[src]Reads a WebAssembly string from the module.
Errors
If BinaryReader
has less than up to four bytes remaining, the string’s
length exceeds the remaining bytes, the string’s length exceeds
limits::MAX_WASM_STRING_SIZE
, or the string contains invalid utf-8.
pub fn read_operator(&mut self) -> Result<Operator<'a>, BinaryReaderError>
[src]
pub fn read_operator(&mut self) -> Result<Operator<'a>, BinaryReaderError>
[src]Reads the next available Operator
.
Errors
If BinaryReader
has less bytes remaining than required to parse
the Operator
.
Trait Implementations
impl<'a> Clone for BinaryReader<'a>
[src]
impl<'a> Clone for BinaryReader<'a>
[src]pub fn clone(&self) -> BinaryReader<'a>
[src]
pub fn clone(&self) -> BinaryReader<'a>
[src]Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]Performs copy-assignment from source
. Read more
impl<'a> Debug for BinaryReader<'a>
[src]
impl<'a> Debug for BinaryReader<'a>
[src]Auto Trait Implementations
impl<'a> RefUnwindSafe for BinaryReader<'a>
impl<'a> Send for BinaryReader<'a>
impl<'a> Sync for BinaryReader<'a>
impl<'a> Unpin for BinaryReader<'a>
impl<'a> UnwindSafe for BinaryReader<'a>
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more