Union wasmtime_runtime::ValRaw
source · #[repr(C)]
pub union ValRaw {
/* private fields */
}
Expand description
A “raw” and unsafe representation of a WebAssembly value.
This is provided for use with the Func::new_unchecked
and
Func::call_unchecked
APIs. In general it’s unlikely you should be using
this from Rust, rather using APIs like Func::wrap
and TypedFunc::call
.
This is notably an “unsafe” way to work with Val
and it’s recommended to
instead use Val
where possible. An important note about this union is that
fields are all stored in little-endian format, regardless of the endianness
of the host system.
Implementations§
source§impl ValRaw
impl ValRaw
sourcepub fn u64(i: u64) -> ValRaw
pub fn u64(i: u64) -> ValRaw
Creates a WebAssembly i64
value
Examples found in repository?
src/vmcontext.rs (line 992)
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021
pub fn i32(i: i32) -> ValRaw {
// Note that this is intentionally not setting the `i32` field, instead
// setting the `i64` field with a zero-extended version of `i`. For more
// information on this see the comments on `Lower for Result` in the
// `wasmtime` crate. Otherwise though all `ValRaw` constructors are
// otherwise constrained to guarantee that the initial 64-bits are
// always initialized.
ValRaw::u64((i as u32).into())
}
/// Creates a WebAssembly `i64` value
#[inline]
pub fn i64(i: i64) -> ValRaw {
ValRaw { i64: i.to_le() }
}
/// Creates a WebAssembly `i32` value
#[inline]
pub fn u32(i: u32) -> ValRaw {
// See comments in `ValRaw::i32` for why this is setting the upper
// 32-bits as well.
ValRaw::u64(i.into())
}
/// Creates a WebAssembly `i64` value
#[inline]
pub fn u64(i: u64) -> ValRaw {
ValRaw::i64(i as i64)
}
/// Creates a WebAssembly `f32` value
#[inline]
pub fn f32(i: u32) -> ValRaw {
// See comments in `ValRaw::i32` for why this is setting the upper
// 32-bits as well.
ValRaw::u64(i.into())
}
sourcepub fn get_funcref(&self) -> usize
pub fn get_funcref(&self) -> usize
Gets the WebAssembly funcref
value
sourcepub fn get_externref(&self) -> usize
pub fn get_externref(&self) -> usize
Gets the WebAssembly externref
value