Struct soroban_wasmi::Func
source · [−]#[repr(transparent)]pub struct Func(_);
Expand description
A Wasm or host function reference.
Implementations
sourceimpl Func
impl Func
sourcepub fn wrap<T, Params, Results>(
ctx: impl AsContextMut<UserState = T>,
func: impl IntoFunc<T, Params, Results>
) -> Self
pub fn wrap<T, Params, Results>(
ctx: impl AsContextMut<UserState = T>,
func: impl IntoFunc<T, Params, Results>
) -> Self
Creates a new host function from the given closure.
sourcepub fn func_type(&self, ctx: impl AsContext) -> FuncType
pub fn func_type(&self, ctx: impl AsContext) -> FuncType
Returns the function type of the Func
.
sourcepub fn call<T>(
&self,
ctx: impl AsContextMut<UserState = T>,
inputs: &[Value],
outputs: &mut [Value]
) -> Result<(), Error>
pub fn call<T>(
&self,
ctx: impl AsContextMut<UserState = T>,
inputs: &[Value],
outputs: &mut [Value]
) -> Result<(), Error>
Calls the Wasm or host function with the given inputs.
The result is written back into the outputs
buffer.
Errors
- If the function returned a
Trap
. - If the types of the
inputs
do not match the expected types for the function signature ofself
. - If the number of input values does not match the expected number of
inputs required by the function signature of
self
. - If the number of output values does not match the expected number of
outputs required by the function signature of
self
.
sourcepub fn typed<Params, Results, S>(
&self,
ctx: S
) -> Result<TypedFunc<Params, Results>, Error>where
Params: WasmParams,
Results: WasmResults,
S: AsContext,
pub fn typed<Params, Results, S>(
&self,
ctx: S
) -> Result<TypedFunc<Params, Results>, Error>where
Params: WasmParams,
Results: WasmResults,
S: AsContext,
Trait Implementations
impl Copy for Func
Auto Trait Implementations
impl RefUnwindSafe for Func
impl Send for Func
impl Sync for Func
impl Unpin for Func
impl UnwindSafe for Func
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
impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read morefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read morefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read morefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more