Crate marine_macro[−][src]
Expand description
Defines the #[marine] macro that should be used with all export functions, extern blocks.
At now, It supports the following types that could be used as parameters in export or foreign
functions: i8, i16, i32, i64, u8, u16, u32, u64, f32, f64, bool, String, Vec
Examples
This example shows how a function could be exported:
ⓘ
#[marine] pub fn greeting(name: String) -> String { format!("Hi {}", name) }
This more complex example shows how a function could be imported from another Wasm module and how a struct could be passed:
ⓘ
use fluence::MountedBinaryResult; #[marine] pub fn read_ipfs_file(file_path: String) -> MountedBinaryResult { let hash = calculate_hash(file_path); ipfs(vec![hash]) } #[marine] #[link(wasm_import_module = "ipfs_node")] extern "C" { pub fn ipfs(file_hash: Vec<String>) -> MountedBinaryResult; }
Attribute Macros
fce | Deprecated |
marine |