#[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§

Creates a WebAssembly i32 value

Creates a WebAssembly i64 value

Examples found in repository?
src/vmcontext.rs (line 1012)
1011
1012
1013
    pub fn u64(i: u64) -> ValRaw {
        ValRaw::i64(i as i64)
    }

Creates a WebAssembly i32 value

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())
    }

Creates a WebAssembly f32 value

Creates a WebAssembly f64 value

Creates a WebAssembly v128 value

Creates a WebAssembly funcref value

Creates a WebAssembly externref value

Gets the WebAssembly i32 value

Examples found in repository?
src/vmcontext.rs (line 1064)
1063
1064
1065
    pub fn get_u32(&self) -> u32 {
        self.get_i32() as u32
    }

Gets the WebAssembly i64 value

Examples found in repository?
src/vmcontext.rs (line 1070)
1069
1070
1071
    pub fn get_u64(&self) -> u64 {
        self.get_i64() as u64
    }

Gets the WebAssembly i32 value

Gets the WebAssembly i64 value

Gets the WebAssembly f32 value

Gets the WebAssembly f64 value

Gets the WebAssembly v128 value

Gets the WebAssembly funcref value

Gets the WebAssembly externref value

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.