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

Function wasmtime_structref_set_field

crates/c-api/src/structref.rs:97–113  ·  view source on GitHub ↗
(
    mut cx: WasmtimeStoreContextMut<'_>,
    structref: Option<&wasmtime_structref_t>,
    index: usize,
    val: &crate::wasmtime_val_t,
)

Source from the content-addressed store, hash-verified

95
96#[unsafe(no_mangle)]
97pub unsafe extern "C" fn wasmtime_structref_set_field(
98 mut cx: WasmtimeStoreContextMut<'_>,
99 structref: Option<&wasmtime_structref_t>,
100 index: usize,
101 val: &crate::wasmtime_val_t,
102) -> Option<Box<crate::wasmtime_error_t>> {
103 let structref = structref
104 .and_then(|s| s.as_wasmtime())
105 .expect("non-null structref required");
106 let mut scope = RootScope::new(&mut cx);
107 let rooted = structref.to_rooted(&mut scope);
108 let rust_val = val.to_val(&mut scope);
109 match rooted.set_field(&mut scope, index, rust_val) {
110 Ok(()) => None,
111 Err(e) => Some(Box::new(e.into())),
112 }
113}
114
115#[unsafe(no_mangle)]
116pub unsafe extern "C" fn wasmtime_structref_type(

Callers 1

set_fieldMethod · 0.85

Calls 6

as_wasmtimeMethod · 0.80
to_valMethod · 0.80
newFunction · 0.50
expectMethod · 0.45
to_rootedMethod · 0.45
set_fieldMethod · 0.45

Tested by

no test coverage detected