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

Method try_from

crates/fuzzing/src/generators/value.rs:304–323  ·  view source on GitHub ↗
(ty: wasmtime::ValType)

Source from the content-addressed store, hash-verified

302impl TryFrom<wasmtime::ValType> for DiffValueType {
303 type Error = &'static str;
304 fn try_from(ty: wasmtime::ValType) -> Result<Self, Self::Error> {
305 use wasmtime::ValType::*;
306 match ty {
307 I32 => Ok(Self::I32),
308 I64 => Ok(Self::I64),
309 F32 => Ok(Self::F32),
310 F64 => Ok(Self::F64),
311 V128 => Ok(Self::V128),
312 Ref(r) => match (r.is_nullable(), r.heap_type()) {
313 (true, HeapType::Func) => Ok(Self::FuncRef),
314 (true, HeapType::Extern) => Ok(Self::ExternRef),
315 (true, HeapType::Any) => Ok(Self::AnyRef),
316 (true, HeapType::I31) => Ok(Self::AnyRef),
317 (true, HeapType::None) => Ok(Self::AnyRef),
318 (true, HeapType::Exn) => Ok(Self::ExnRef),
319 (true, HeapType::Cont) => Ok(Self::ContRef),
320 _ => Err("non-null reference types are not supported yet"),
321 },
322 }
323 }
324}
325
326/// Enumerate the types of v128.

Callers

nothing calls this directly

Calls 3

OkFunction · 0.85
is_nullableMethod · 0.80
heap_typeMethod · 0.80

Tested by

no test coverage detected