MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / run_push_event

Function run_push_event

compiler/src/main/exports.rs:243–259  ·  view source on GitHub ↗
(ptr: *const u8, len: u32)

Source from the content-addressed store, hash-verified

241
242#[unsafe(no_mangle)]
243pub unsafe extern "C" fn run_push_event(ptr: *const u8, len: u32) -> i32 {
244 let bytes = unsafe { safe_bytes(ptr, len) };
245 let s = match core::str::from_utf8(bytes) {
246 Ok(s) => s.to_string(),
247 Err(_) => return 1,
248 };
249 with_runtime(|rt| {
250 let Some(paused) = rt.paused_run.as_mut() else { return 1; };
251 let Some(vm) = paused.vm.as_mut() else { return 1; };
252 let val = match vm.heap.alloc(HeapObj::Str(s)) {
253 Ok(v) => v,
254 Err(_) => return 2,
255 };
256 vm.inject_event(val);
257 0
258 })
259}
260
261/* `set_host_*` prologue: take `handle`'s Val (1 = stale) and run `f` on the paused VM (3 = no paused run). */
262fn with_paused_vm(handle: u32, f: impl FnOnce(&mut VM<'static>, crate::modules::vm::types::Val) -> i32) -> i32 {

Callers

nothing calls this directly

Calls 4

safe_bytesFunction · 0.85
with_runtimeFunction · 0.85
inject_eventMethod · 0.80
allocMethod · 0.45

Tested by

no test coverage detected