From 6a1d490a30bbfd6710d73c575979c0b2e64755e4 Mon Sep 17 00:00:00 2001 From: Ivan Enderlin Date: Wed, 30 Oct 2019 14:59:20 +0100 Subject: [PATCH] doc(runtimecore) Explain `ExternalFunctionKind` with more details. --- lib/runtime-core/src/typed_func.rs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/runtime-core/src/typed_func.rs b/lib/runtime-core/src/typed_func.rs index 66c68845e6c..f70f169297e 100644 --- a/lib/runtime-core/src/typed_func.rs +++ b/lib/runtime-core/src/typed_func.rs @@ -131,10 +131,32 @@ pub trait WasmTypeList { } /// Empty trait to specify the kind of `ExternalFunction`: With or -/// without a `vm::Ctx` argument. +/// without a `vm::Ctx` argument. See the `ExplicitVmCtx` and the +/// `ImplicitVmCtx` structures. +/// +/// This type is never aimed to be used by a user. It is used by the +/// trait system to automatically generate an appropriate `wrap` +/// function. pub trait ExternalFunctionKind {} +/// This empty structure indicates that an external function must +/// contain an explicit `vm::Ctx` argument (at first position). +/// +/// ```rs,ignore +/// fn add_one(_: mut &vm::Ctx, x: i32) -> i32 { +/// x + 1 +/// } +/// ``` pub struct ExplicitVmCtx {} + +/// This empty structure indicates that an external function has no +/// `vm::Ctx` argument (at first position). Its signature is: +/// +/// ```rs,ignore +/// fn add_one(x: i32) -> i32 { +/// x + 1 +/// } +/// ``` pub struct ImplicitVmCtx {} impl ExternalFunctionKind for ExplicitVmCtx {}