pub struct Runtime { /* private fields */ }Expand description
State for batching operations and object storage. Every evaluation is a batch - it may just have one operation.
Also stores exported Rust structs and callback functions.
Implementations§
Source§impl Runtime
impl Runtime
Sourcepub fn observe_js_heap_id(&mut self, id: u64)
pub fn observe_js_heap_id(&mut self, id: u64)
Record a JS-allocated heap ID from a response.
Sourcepub fn get_next_placeholder_id(&mut self) -> u64
pub fn get_next_placeholder_id(&mut self) -> u64
Get the next heap ID for a return value placeholder.
Sourcepub fn get_next_inbound_js_heap_id(&mut self) -> u64
pub fn get_next_inbound_js_heap_id(&mut self) -> u64
Allocate the next ID for a JS object sent without encoding an ID. The ID joins the pending install batch shipped on the next Rust-to-JS message.
Sourcepub fn get_next_borrow_id(&mut self) -> u64
pub fn get_next_borrow_id(&mut self) -> u64
Get the next borrow ID from the borrow stack (indices 1-127). The borrow stack grows downward from JSIDX_OFFSET (128) toward 1. Panics if the borrow stack overflows (more than 127 borrowed refs in one operation).
Sourcepub fn push_borrow_frame(&mut self)
pub fn push_borrow_frame(&mut self)
Push a borrow frame before a nested operation that may use borrowed refs. This saves the current borrow stack pointer so we can restore it later.
Sourcepub fn pop_borrow_frame(&mut self)
pub fn pop_borrow_frame(&mut self)
Pop a borrow frame after a nested operation completes. This restores the borrow stack pointer to where it was before the nested operation.
Sourcepub fn release_heap_id(&mut self, id: u64) -> Option<u64>
pub fn release_heap_id(&mut self, id: u64) -> Option<u64>
Track a heap ID as released and queue it for JS drop when appropriate. Returns the ID when there is no open operation frame to batch it into, signalling the caller to notify JS immediately.