Crate fluence_sdk_macro[][src]

Defines the #[fce] 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. Also struct where all fields are public and have aforementioned types could be used as parameters. In this case #[fce] should be also applied to this structs.

Examples

This example shows how a function could be exported:

#[fce]
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;

#[fce]
pub fn read_ipfs_file(file_path: String) -> MountedBinaryResult {
    let hash = calculate_hash(file_path);
    ipfs(vec![hash])
}

#[fce]
#[link(wasm_import_module = "ipfs_node")]
extern "C" {
    pub fn ipfs(file_hash: Vec<String>) -> MountedBinaryResult;
}

Attribute Macros

fce