MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new

Method new

crates/debugger/src/host/api.rs:45–60  ·  view source on GitHub ↗
(store: impl wasmtime::AsContextMut, val: Val)

Source from the content-addressed store, hash-verified

43
44impl WasmValue {
45 pub(crate) fn new(store: impl wasmtime::AsContextMut, val: Val) -> Result<WasmValue> {
46 Ok(match val {
47 Val::ExnRef(Some(rooted)) => {
48 WasmValue::Exn(Some(rooted.to_owned_rooted(store).unwrap()))
49 }
50 Val::ExnRef(None) => WasmValue::Exn(None),
51 Val::FuncRef(Some(f)) => WasmValue::Func(Some(f)),
52 Val::FuncRef(None) => WasmValue::Func(None),
53 Val::ExternRef(_) | Val::AnyRef(_) | Val::ContRef(_) => {
54 return Err(wit::Error::UnsupportedType.into());
55 }
56 Val::I32(_) | Val::I64(_) | Val::F32(_) | Val::F64(_) | Val::V128(_) => {
57 WasmValue::Primitive(val)
58 }
59 })
60 }
61
62 pub(crate) fn into_val(self, store: impl wasmtime::AsContextMut) -> Val {
63 match self {

Callers

nothing calls this directly

Calls 4

OkFunction · 0.85
FuncClass · 0.50
unwrapMethod · 0.45
to_owned_rootedMethod · 0.45

Tested by

no test coverage detected