26 releases (8 breaking)

0.14.0 Feb 21, 2024
0.12.0 Feb 8, 2024
0.10.3 Dec 28, 2023
0.10.1 Oct 24, 2023
0.6.10 Jun 15, 2021

#29 in #marine

Download history 1470/week @ 2023-12-24 568/week @ 2023-12-31 1082/week @ 2024-01-07 838/week @ 2024-01-14 959/week @ 2024-01-21 831/week @ 2024-01-28 727/week @ 2024-02-04 1186/week @ 2024-02-11 5213/week @ 2024-02-18 1481/week @ 2024-02-25 2308/week @ 2024-03-03 1487/week @ 2024-03-10 1365/week @ 2024-03-17 1152/week @ 2024-03-24 1106/week @ 2024-03-31 816/week @ 2024-04-07

4,589 downloads per month
Used in 40 crates (4 directly)

Apache-2.0

145KB
3K SLoC

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.

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

Dependencies

~1.4–2.1MB
~49K SLoC