Struct WasmObject

Source
pub struct WasmObject<'data> { /* private fields */ }
Expand description

Wasm object container (.wasm), used for executables and debug companions on web and wasi.

This can only parse binary wasm file and not wast files.

Implementations§

Source§

impl<'data> WasmObject<'data>

Source

pub fn parse(data: &'data [u8]) -> Result<Self, WasmError>

Tries to parse a WASM from the given slice.

Source§

impl<'data> WasmObject<'data>

Source

pub fn test(data: &[u8]) -> bool

Tests whether the buffer could contain a WASM object.

Source

pub fn file_format(&self) -> FileFormat

The container file format, which currently is always FileFormat::Wasm.

Source

pub fn code_id(&self) -> Option<CodeId>

The code identifier of this object.

Wasm does not yet provide code IDs.

Source

pub fn debug_id(&self) -> DebugId

The debug information identifier of a WASM file.

Wasm does not yet provide debug IDs.

Source

pub fn arch(&self) -> Arch

The CPU architecture of this object.

Source

pub fn kind(&self) -> ObjectKind

The kind of this object.

Source

pub fn load_address(&self) -> u64

The address at which the image prefers to be loaded into memory.

This is always 0 as this does not really apply to WASM.

Source

pub fn has_symbols(&self) -> bool

Determines whether this object exposes a public symbol table.

Source

pub fn symbols(&self) -> WasmSymbolIterator<'data, '_>

Returns an iterator over symbols in the public symbol table.

Source

pub fn symbol_map(&self) -> SymbolMap<'data>

Returns an ordered map of symbols in the symbol table.

Source

pub fn has_debug_info(&self) -> bool

Determines whether this object contains debug information.

Source

pub fn debug_session(&self) -> Result<DwarfDebugSession<'data>, DwarfError>

Constructs a debugging session.

Source

pub fn has_unwind_info(&self) -> bool

Determines whether this object contains stack unwinding information.

Source

pub fn has_sources(&self) -> bool

Determines whether this object contains embedded source.

Source

pub fn is_malformed(&self) -> bool

Determines whether this object is malformed and was only partially parsed

Source

pub fn data(&self) -> &'data [u8]

Returns the raw data of the WASM file.

Source

pub fn code_offset(&self) -> u64

Returns the offset of the code section.

Trait Implementations§

Source§

impl<'slf, 'd: 'slf> AsSelf<'slf> for WasmObject<'d>

Source§

type Ref = WasmObject<'slf>

The Self type with 'slf lifetimes, returned by as_self.
Source§

fn as_self(&'slf self) -> &'slf Self::Ref

Returns a reference to self with downcasted lifetime.
Source§

impl Debug for WasmObject<'_>

Source§

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

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

impl<'data> Dwarf<'data> for WasmObject<'data>

Source§

fn endianity(&self) -> Endian

Returns whether the file was compiled for a big-endian or little-endian machine. Read more
Source§

fn raw_section(&self, section_name: &str) -> Option<DwarfSection<'data>>

Returns information and raw data of a section. Read more
Source§

fn section(&self, name: &str) -> Option<DwarfSection<'data>>

Returns information and data of a section. Read more
Source§

fn has_section(&self, name: &str) -> bool

Determines whether the specified section exists. Read more
Source§

impl<'data: 'object, 'object> ObjectLike<'data, 'object> for WasmObject<'data>

Source§

type Error = DwarfError

Errors thrown when reading information from this object.
Source§

type Session = DwarfDebugSession<'data>

A session that allows optimized access to debugging information.
Source§

type SymbolIterator = WasmSymbolIterator<'data, 'object>

The iterator over the symbols in the public symbol table.
Source§

fn file_format(&self) -> FileFormat

The container format of this file.
Source§

fn code_id(&self) -> Option<CodeId>

The code identifier of this object. Read more
Source§

fn debug_id(&self) -> DebugId

The debug information identifier of this object.
Source§

fn arch(&self) -> Arch

The CPU architecture of this object.
Source§

fn kind(&self) -> ObjectKind

The kind of this object.
Source§

fn load_address(&self) -> u64

The address at which the image prefers to be loaded into memory.
Source§

fn has_symbols(&self) -> bool

Determines whether this object exposes a public symbol table.
Source§

fn symbols(&'object self) -> Self::SymbolIterator

Returns an iterator over symbols in the public symbol table.
Source§

fn symbol_map(&self) -> SymbolMap<'data>

Returns an ordered map of symbols in the symbol table.
Source§

fn has_debug_info(&self) -> bool

Determines whether this object contains debug information.
Source§

fn debug_session(&self) -> Result<Self::Session, Self::Error>

Constructs a debugging session. Read more
Source§

fn has_unwind_info(&self) -> bool

Determines whether this object contains stack unwinding information.
Source§

fn has_sources(&self) -> bool

Determines whether this object contains embedded sources.
Source§

fn is_malformed(&self) -> bool

Determines whether this object is malformed and was only partially parsed

Auto Trait Implementations§

§

impl<'data> Freeze for WasmObject<'data>

§

impl<'data> RefUnwindSafe for WasmObject<'data>

§

impl<'data> Send for WasmObject<'data>

§

impl<'data> Sync for WasmObject<'data>

§

impl<'data> Unpin for WasmObject<'data>

§

impl<'data> UnwindSafe for WasmObject<'data>

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<I, T> ExtractContext<I, ()> for T

Source§

fn extract_context(self, _original_input: I)

Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. 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<I> RecreateContext<I> for I

Source§

fn recreate_context(_original_input: I, tail: I) -> I

Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. 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.