Attribute Macro sewup_derive::ewasm_lib_fn [−][src]
#[ewasm_lib_fn]
Expand description
helps you to build your handler in other module
This macro will automatically generated as {FUNCTION_NAME}_SIG
ⓘ
// module.rs
use sewup::ewasm_api;
#[ewasm_lib_fn]
pub fn symbol(s: &str) {
let symbol = s.to_string().into_bytes();
ewasm_api::finish_data(&symbol);
}
ⓘ
// lib.rs
use module::{symbol, SYMBOL_SIG};
#[ewasm_main]
fn main() -> Result<()> {
let contract = Contract::new()?;
match contract.get_function_selector()? {
SYMBOL_SIG => symbol("ETD"),
_ => return Err(Error::UnknownHandle.into()),
};
Ok(())
}