MCPcopy Index your code
hub / github.com/RustPython/RustPython / kv_put

Function kv_put

example_projects/wasm32_without_js/wasm-runtime/src/main.rs:44–54  ·  view source on GitHub ↗

kp and kl are the key pointer and length in wasm memory, vp and vl are for the value

(mut ctx: FunctionEnvMut<Ctx>, kp: i32, kl: i32, vp: i32, vl: i32)

Source from the content-addressed store, hash-verified

42
43/// kp and kl are the key pointer and length in wasm memory, vp and vl are for the value
44fn kv_put(mut ctx: FunctionEnvMut<Ctx>, kp: i32, kl: i32, vp: i32, vl: i32) -> i32 {
45 let (c, s) = ctx.data_and_store_mut();
46 let mut key = vec![0u8; kl as usize];
47 let mut val = vec![0u8; vl as usize];
48 let m = c.mem.as_ref().unwrap().view(&s);
49 if m.read(kp as u64, &mut key).is_err() || m.read(vp as u64, &mut val).is_err() {
50 return -1;
51 }
52 c.kv.insert(key, val);
53 0
54}
55
56// // p and l are the buffer pointer and length in wasm memory.
57// fn get_code(mut ctx:FunctionEnvMut<Ctx>, p: i32, l: i32) -> i32 {

Callers

nothing calls this directly

Calls 5

is_errMethod · 0.80
unwrapMethod · 0.45
as_refMethod · 0.45
readMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected