Struct walrus::ModuleFunctions

source ·
pub struct ModuleFunctions { /* private fields */ }
Expand description

The set of functions within a module.

Implementations§

source§

impl ModuleFunctions

source

pub fn new() -> ModuleFunctions

Construct a new, empty set of functions for a module.

source

pub fn add_import(&mut self, ty: TypeId, import: ImportId) -> FunctionId

Create a new externally defined, imported function.

source

pub fn add_local(&mut self, func: LocalFunction) -> FunctionId

Create a new internally defined function

source

pub fn get(&self, id: FunctionId) -> &Function

Gets a reference to a function given its id

source

pub fn get_mut(&mut self, id: FunctionId) -> &mut Function

Gets a reference to a function given its id

source

pub fn by_name(&self, name: &str) -> Option<FunctionId>

Get a function ID by its name.

The name used is the “name” custom section name and not the export name, if a function happens to be exported.

Note that function names are not guaranteed to be unique. This will return the first function in the module with the given name.

source

pub fn delete(&mut self, id: FunctionId)

Removes a function from this module.

It is up to you to ensure that any potential references to the deleted function are also removed, eg call expressions, exports, table elements, etc.

source

pub fn iter(&self) -> impl Iterator<Item = &Function>

Get a shared reference to this module’s functions.

source

pub fn iter_local(&self) -> impl Iterator<Item = (FunctionId, &LocalFunction)>

Get an iterator of this module’s local functions

source

pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut Function>

Get a mutable reference to this module’s functions.

source

pub fn iter_local_mut( &mut self ) -> impl Iterator<Item = (FunctionId, &mut LocalFunction)>

Get an iterator of this module’s local functions

Trait Implementations§

source§

impl Debug for ModuleFunctions

source§

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

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

impl Default for ModuleFunctions

source§

fn default() -> ModuleFunctions

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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

§

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.