mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 13:18:20 +00:00
Seal HostFunctionKind trait
This commit is contained in:
12
lib/api/src/js/externals/function.rs
vendored
12
lib/api/src/js/externals/function.rs
vendored
@@ -901,7 +901,7 @@ mod inner {
|
||||
/// the trait system to automatically generate the appropriate
|
||||
/// host functions.
|
||||
#[doc(hidden)]
|
||||
pub trait HostFunctionKind {}
|
||||
pub trait HostFunctionKind: private::HostFunctionKindSealed {}
|
||||
|
||||
/// An empty struct to help Rust typing to determine
|
||||
/// when a `HostFunction` does have an environment.
|
||||
@@ -915,6 +915,16 @@ mod inner {
|
||||
|
||||
impl HostFunctionKind for WithoutEnv {}
|
||||
|
||||
mod private {
|
||||
//! Sealing the HostFunctionKind because it shouldn't be implemented
|
||||
//! by any type outside.
|
||||
//! See:
|
||||
//! https://rust-lang.github.io/api-guidelines/future-proofing.html#c-sealed
|
||||
pub trait HostFunctionKindSealed {}
|
||||
impl HostFunctionKindSealed for super::WithEnv {}
|
||||
impl HostFunctionKindSealed for super::WithoutEnv {}
|
||||
}
|
||||
|
||||
/// Represents a low-level Wasm static host function. See
|
||||
/// `super::Function::new` and `super::Function::new_env` to learn
|
||||
/// more.
|
||||
|
||||
Reference in New Issue
Block a user