cranelift_wasm::wasmparser

Struct SectionLimited

Source
pub struct SectionLimited<'a, T> { /* private fields */ }
Expand description

A generic structure for reading a section of a WebAssembly binary which has a limited number of items within it.

Many WebAssembly sections are a count of items followed by that many items. This helper structure can be used to parse these sections and provides an iteration-based API for reading the contents.

Note that this always implements the Clone trait to represent the ability to parse the section multiple times.

Implementations§

Source§

impl<'a> SectionLimited<'a, RecGroup>

Source

pub fn into_iter_err_on_gc_types( self, ) -> impl Iterator<Item = Result<FuncType, BinaryReaderError>> + 'a

Returns an iterator over this type section which will only yield function types and any usage of GC types from the GC proposal will be translated into an error.

Source§

impl<'a, T> SectionLimited<'a, T>

Source

pub fn new( reader: BinaryReader<'a>, ) -> Result<SectionLimited<'a, T>, BinaryReaderError>

Creates a new section reader from the provided contents.

The data provided here is the data of the section itself that will be parsed. The offset argument is the byte offset, in the original wasm binary, that the section was found. The offset argument is used for error reporting.

§Errors

Returns an error if a 32-bit count couldn’t be read from the data.

Source

pub fn count(&self) -> u32

Returns the count of total items within this section.

Source

pub fn original_position(&self) -> usize

Returns whether the original byte offset of this section.

Source

pub fn range(&self) -> Range<usize>

Returns the range, as byte offsets, of this section within the original wasm binary.

Source

pub fn into_iter_with_offsets(self) -> SectionLimitedIntoIterWithOffsets<'a, T>
where T: FromReader<'a>,

Returns an iterator which yields not only each item in this section but additionally the offset of each item within the section.

Trait Implementations§

Source§

impl<T> Clone for SectionLimited<'_, T>

Source§

fn clone(&self) -> SectionLimited<'_, T>

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<T> Debug for SectionLimited<'_, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'a, T> IntoIterator for SectionLimited<'a, T>
where T: FromReader<'a>,

Source§

type Item = Result<T, BinaryReaderError>

The type of the elements being iterated over.
Source§

type IntoIter = SectionLimitedIntoIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> <SectionLimited<'a, T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for SectionLimited<'a, T>

§

impl<'a, T> RefUnwindSafe for SectionLimited<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for SectionLimited<'a, T>
where T: Send,

§

impl<'a, T> Sync for SectionLimited<'a, T>
where T: Sync,

§

impl<'a, T> Unpin for SectionLimited<'a, T>
where T: Unpin,

§

impl<'a, T> UnwindSafe for SectionLimited<'a, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.