From 85c51c7d34d1b4e52f436142938baf3e2425d247 Mon Sep 17 00:00:00 2001 From: boneyard93501 Date: Thu, 10 Jun 2021 18:39:02 +0000 Subject: [PATCH] GitBook: [main] 54 pages modified --- .../marine/marine-rs-sdk.md | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/knowledge_knowledge/knowledge_aquamarine/marine/marine-rs-sdk.md b/knowledge_knowledge/knowledge_aquamarine/marine/marine-rs-sdk.md index ec47c76..d438f7e 100644 --- a/knowledge_knowledge/knowledge_aquamarine/marine/marine-rs-sdk.md +++ b/knowledge_knowledge/knowledge_aquamarine/marine/marine-rs-sdk.md @@ -55,5 +55,30 @@ Function Export Requirements #### Function Import +The `[marine]` macro can also wrap an [`extern` block](https://doc.rust-lang.org/std/keyword.extern.html). In this case, all functions declared in it are considered imported functions. If there are imported functions in some module, say, module A, then: + +* There should be another module, module B, that exports the same functions. The name of module B is indicated in the `link` macro \(see examples below\). +* Module B should be loaded to `Marine` by the moment the loading of module A starts. Module A cannot be loaded if at least one imported function is absent in `Marine`. + +```text +#[marine] +pub struct TestRecord { + pub field_0: i32, + pub field_1: Vec>, +} + +// wrap the extern block with the marine macro to expose the function +// as an import to the Marine VM +#[marine] +#[link(wasm_import_module = "some_module")] +extern "C" { + pub fn foo(arg: Vec>>>, arg_2: String) -> Vec>>>; +} +``` + + + + +