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


This example shows how a function could be exported:

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 marine_rs_sdk::MountedBinaryResult;

pub fn read_ipfs_file(file_path: String) -> MountedBinaryResult {
    let hash = calculate_hash(file_path);

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

Attribute Macros