Struct wasmparser::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, T> SectionLimited<'a, T>
impl<'a, T> SectionLimited<'a, T>
sourcepub fn new(data: &'a [u8], offset: usize) -> Result<Self>
pub fn new(data: &'a [u8], offset: usize) -> Result<Self>
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
.
sourcepub fn original_position(&self) -> usize
pub fn original_position(&self) -> usize
Returns whether the original byte offset of this section.
sourcepub fn range(&self) -> Range<usize>
pub fn range(&self) -> Range<usize>
Returns the range, as byte offsets, of this section within the original wasm binary.
sourcepub fn into_iter_with_offsets(self) -> SectionLimitedIntoIterWithOffsets<'a, T> ⓘwhere
T: FromReader<'a>,
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>
impl<T> Clone for SectionLimited<'_, T>
source§impl<T> Debug for SectionLimited<'_, T>
impl<T> Debug for SectionLimited<'_, T>
source§impl<'a, T> IntoIterator for SectionLimited<'a, T>where
T: FromReader<'a>,
impl<'a, T> IntoIterator for SectionLimited<'a, T>where
T: FromReader<'a>,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)