pub struct WasmFile {
pub bytes: Vec<u8>,
pub version: u32,
pub sections: Vec<Section>,
}Expand description
A parsed WASM module. bytes is the verbatim input; the
sections list records where each section starts and ends
so callers can read or rewrite them without re-parsing.
Fields§
§bytes: Vec<u8>§version: u32§sections: Vec<Section>Implementations§
Source§impl WasmFile
impl WasmFile
Sourcepub fn parse(bytes: &[u8]) -> Result<Self>
pub fn parse(bytes: &[u8]) -> Result<Self>
Parse bytes into a WasmFile. The bytes are
retained verbatim so Self::write_to_vec can
reproduce them.
Sourcepub fn write_to_vec(&self) -> Vec<u8> ⓘ
pub fn write_to_vec(&self) -> Vec<u8> ⓘ
Reproduce the original bytes. Currently a clone — when section editing lands the layout-rebuild logic will live here.
Sourcepub fn section_body(&self, section: &Section) -> &[u8] ⓘ
pub fn section_body(&self, section: &Section) -> &[u8] ⓘ
Body bytes of section (excluding the id + size header).
Sourcepub fn custom_section_name(&self, section: &Section) -> Option<String>
pub fn custom_section_name(&self, section: &Section) -> Option<String>
For a custom (id = 0) section, return its decoded name
(UTF-8). The name is a LEB128-length-prefixed string at
the start of the body. Returns None for non-custom
sections or malformed names.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WasmFile
impl RefUnwindSafe for WasmFile
impl Send for WasmFile
impl Sync for WasmFile
impl Unpin for WasmFile
impl UnsafeUnpin for WasmFile
impl UnwindSafe for WasmFile
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
Mutably borrows from an owned value. Read more