Macro sewup_derive::ewasm_fn_sig [−][src]
ewasm_fn_sig!() { /* proc-macro */ }
Expand description
helps you get you function signature
- provide function name to get function signature from the same namespace,
which function should be decorated with
#[ewasm_fn]
, for example,ewasm_fn_sig!(contract_handler)
ⓘ
#[ewasm_fn]
fn decorated_handler(a: i32, b: String) -> Result<()> {
Ok(())
}
#[ewasm_main]
fn main() -> Result<()> {
let contract = Contract::new()?;
match contract.get_function_selector()? {
ewasm_fn_sig!(decorated_handler) => ewasm_input_from!(contract move decorated_handler)?,
_ => return Err(Error::UnknownHandle.into()),
};
Ok(())
}
- provide a function name with input parameters then the macro will
calculate the correct functional signature for you.
ex:
ewasm_fn_sig!(undecorated_handler( a: i32, b: String ))
ⓘ
// some_crate.rs
pub fn decorated_handler(a: i32, b: String) -> Result<()> {
Ok(())
}
ⓘ
use some_crate::decorated_handler;
#[ewasm_main]
fn main() -> Result<()> {
let contract = Contract::new()?;
match contract.get_function_selector()? {
ewasm_fn_sig!(undecorated_handler(a: i32, b: String))
=> ewasm_input_from!(contract move undecorated_handler)?,
_ => return Err(Error::UnknownHandle.into()),
};
Ok(())
}