pub struct BridgeCallContext {
pub session_id: String,
/* private fields */
}Expand description
Context for sync-blocking bridge calls from a V8 session.
Holds the frame sender and response receiver, session ID, call_id counter, and pending-call tracking. Used by V8 FunctionTemplate callbacks to implement the sync-blocking bridge pattern.
Fields§
§session_id: StringSession ID included in every BridgeCall
Implementations§
Source§impl BridgeCallContext
impl BridgeCallContext
Sourcepub fn stub() -> Self
pub fn stub() -> Self
Create a no-op BridgeCallContext for snapshot stub functions. Panics if sync_call or async_send is called — stubs exist only for the bridge IIFE to reference (not call) during snapshot creation.
Sourcepub fn new(
writer: Box<dyn Write + Send>,
reader: Box<dyn Read + Send>,
session_id: String,
) -> Self
pub fn new( writer: Box<dyn Write + Send>, reader: Box<dyn Read + Send>, session_id: String, ) -> Self
Create a BridgeCallContext with a byte writer and reader (wraps in WriterFrameSender and ReaderResponseReceiver). Convenient for tests that pre-serialize BridgeResponse bytes.
Sourcepub fn with_receiver(
sender: Box<dyn RuntimeEventSender>,
response_rx: Box<dyn BridgeResponseReceiver>,
session_id: String,
router: CallIdRouter,
shared_call_id: SharedCallIdCounter,
) -> Self
pub fn with_receiver( sender: Box<dyn RuntimeEventSender>, response_rx: Box<dyn BridgeResponseReceiver>, session_id: String, router: CallIdRouter, shared_call_id: SharedCallIdCounter, ) -> Self
Create a BridgeCallContext with a FrameSender, ResponseReceiver, call_id routing table, and shared call_id counter. All sessions sharing the same CallIdRouter must share the same counter to prevent call_id collisions in the routing table.
Sourcepub fn sync_call_response(
&self,
method: &str,
args: Vec<u8>,
) -> Result<Option<SyncBridgeCallResponse>, String>
pub fn sync_call_response( &self, method: &str, args: Vec<u8>, ) -> Result<Option<SyncBridgeCallResponse>, String>
Perform a sync-blocking bridge call.
Generates a unique call_id, sends a BridgeCall message over IPC, blocks on read() for the BridgeResponse, and returns the result. Error responses from the host are returned as Err.
pub fn sync_call( &self, method: &str, args: Vec<u8>, ) -> Result<Option<Vec<u8>>, String>
Sourcepub fn async_send(&self, method: &str, args: Vec<u8>) -> Result<u64, String>
pub fn async_send(&self, method: &str, args: Vec<u8>) -> Result<u64, String>
Send a BridgeCall without blocking for a response. Returns the call_id for later matching with BridgeResponse. Used by async promise-returning bridge functions.
Sourcepub fn is_call_pending(&self, call_id: u64) -> bool
pub fn is_call_pending(&self, call_id: u64) -> bool
Check if a call_id is currently pending.
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of pending calls.