Documentation.
This commit is contained in:
parent
da384ed27a
commit
cd9bcc073a
|
@ -1,9 +1,13 @@
|
|||
//! This module contains auxilary functions which one might find useful for
|
||||
//! generating implementations of host related functionality like `Externals`.
|
||||
|
||||
use nan_preserving_float::{F32, F64};
|
||||
use {RuntimeValue, Trap, ValueType};
|
||||
|
||||
/// A trait that represents a value that can be directly coerced to one of
|
||||
/// wasm base value types.
|
||||
pub trait IntoWasmValue {
|
||||
/// The value type into which the self type is converted.
|
||||
const VALUE_TYPE: ValueType;
|
||||
/// Perform the conversion.
|
||||
fn into_wasm_value(self) -> RuntimeValue;
|
||||
|
@ -28,8 +32,15 @@ impl_convertible_to_wasm!(u64, I64, as i64);
|
|||
impl_convertible_to_wasm!(F32, F32);
|
||||
impl_convertible_to_wasm!(F64, F64);
|
||||
|
||||
/// A trait that represents a value that can be returned from a function.
|
||||
///
|
||||
/// Basically it is superset of `IntoWasmValue` types, adding the ability to return
|
||||
/// the unit value (i.e. `()`) and return a value that signals a trap.
|
||||
pub trait IntoWasmResult {
|
||||
/// The value type into which the self type is converted or `None` in case
|
||||
/// of the unit value (aka `()` aka `void`).
|
||||
const VALUE_TYPE: Option<ValueType>;
|
||||
/// Perform the conversion.
|
||||
fn into_wasm_result(self) -> Result<Option<RuntimeValue>, Trap>;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue