pub struct OperatorsReader<'a> { /* private fields */ }
Expand description

A reader for a core WebAssembly function’s operators.

Implementations§

source§

impl<'a> OperatorsReader<'a>

source

pub fn eof(&self) -> bool

Determines if the reader is at the end of the operators.

source

pub fn original_position(&self) -> usize

Gets the original position of the reader.

source

pub fn allow_memarg64(&mut self, allow: bool)

Whether or not to allow 64-bit memory arguments in the the operators being read.

This is intended to be true when support for the memory64 WebAssembly proposal is also enabled.

source

pub fn ensure_end(&self) -> Result<(), BinaryReaderError>

Ensures the reader is at the end.

This function returns an error if there is extra data after the operators.

source

pub fn read(&mut self) -> Result<Operator<'a>, BinaryReaderError>

Reads an operator from the reader.

source

pub fn into_iter_with_offsets(self) -> OperatorsIteratorWithOffsets<'a>

Converts to an iterator of operators paired with offsets.

source

pub fn read_with_offset( &mut self ) -> Result<(Operator<'a>, usize), BinaryReaderError>

Reads an operator with its offset.

source

pub fn visit_operator<T>( &mut self, visitor: &mut T ) -> Result<<T as VisitOperator<'a>>::Output, BinaryReaderError>where T: VisitOperator<'a>,

Visit a single operator with the specified VisitOperator instance.

See BinaryReader::visit_operator for more information.

source

pub fn get_binary_reader(&self) -> BinaryReader<'a>

Gets a binary reader from this operators reader.

Trait Implementations§

source§

impl<'a> Clone for OperatorsReader<'a>

source§

fn clone(&self) -> OperatorsReader<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> IntoIterator for OperatorsReader<'a>

source§

fn into_iter(self) -> <OperatorsReader<'a> as IntoIterator>::IntoIter

Reads content of the code section.

Examples
use wasmparser::{Operator, CodeSectionReader, Result};
let code_reader = CodeSectionReader::new(data, 0).unwrap();
for body in code_reader {
    let body = body.expect("function body");
    let mut op_reader = body.get_operators_reader().expect("op reader");
    let ops = op_reader.into_iter().collect::<Result<Vec<Operator>>>().expect("ops");
    assert!(
        if let [Operator::Nop, Operator::End] = ops.as_slice() { true } else { false },
        "found {:?}",
        ops
    );
}
§

type Item = Result<Operator<'a>, BinaryReaderError>

The type of the elements being iterated over.
§

type IntoIter = OperatorsIterator<'a>

Which kind of iterator are we turning this into?

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for OperatorsReader<'a>

§

impl<'a> Send for OperatorsReader<'a>

§

impl<'a> Sync for OperatorsReader<'a>

§

impl<'a> Unpin for OperatorsReader<'a>

§

impl<'a> UnwindSafe for OperatorsReader<'a>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.