Struct wasmparser::ModuleReader
source · pub struct ModuleReader<'a> { /* private fields */ }
Expand description
Reads top-level WebAssembly file structure: header and sections.
Implementations
sourceimpl<'a> ModuleReader<'a>
impl<'a> ModuleReader<'a>
pub fn new(data: &[u8]) -> Result<ModuleReader<'_>>
pub fn get_version(&self) -> u32
pub fn current_position(&self) -> usize
pub fn eof(&self) -> bool
sourcepub fn read<'b>(&mut self) -> Result<Section<'b>>where
'a: 'b,
pub fn read<'b>(&mut self) -> Result<Section<'b>>where
'a: 'b,
Reads next top-level record from the WebAssembly binary data. The methods returns reference to current state of the reader.
Examples
use wasmparser::ModuleReader;
let mut reader = ModuleReader::new(data).expect("reader");
let section = reader.read().expect("section #1");
println!("First section {:?}", section);
let section = reader.read().expect("section #2");
println!("Second section {:?}", section);
assert!(!reader.eof(), "there are more sections");
sourcepub fn skip_custom_sections(&mut self) -> Result<()>
pub fn skip_custom_sections(&mut self) -> Result<()>
Skips custom sections.
Examples
use wasmparser::ModuleReader;
use wasmparser::SectionCode;
let mut reader = ModuleReader::new(data).expect("reader");
while { reader.skip_custom_sections(); !reader.eof() } {
let section = reader.read().expect("section");
if let SectionCode::Custom {..} = section.code { panic!("no custom"); }
println!("Section {:?}", section);
}
Trait Implementations
sourceimpl<'a> IntoIterator for ModuleReader<'a>
impl<'a> IntoIterator for ModuleReader<'a>
Auto Trait Implementations
impl<'a> RefUnwindSafe for ModuleReader<'a>
impl<'a> Send for ModuleReader<'a>
impl<'a> Sync for ModuleReader<'a>
impl<'a> Unpin for ModuleReader<'a>
impl<'a> UnwindSafe for ModuleReader<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more