Skip to main content

Module bridge

Module bridge 

Source
Expand description

Hybrid Bridge — sync reads + async mutations communication model.

The engine’s architecture is batch-oriented and frame-driven (like Flutter). Enforcing fully synchronous communication would break the scheduler, layout computation, and “one commit per frame” design.

The hybrid bridge splits JS↔Rust communication into two paths:

┌──────────────────────────────────────────────────────┐ │ SYNC PATH (JSI-like, immediate return) │ │ JS ↔ Rust │ │ • Read-only queries: measure, focus, scroll offset │ │ • Native event → JS callback dispatch │ │ ❌ No UI mutations allowed on this path │ └──────────────────────────────────────────────────────┘

┌──────────────────────────────────────────────────────┐ │ ASYNC PATH (IR / FlatBuffers, frame-batched) │ │ JS → Rust (one-way per frame) │ │ • All mutations: create, update, remove, reparent │ │ • Navigation, layout changes, mount/unmount │ │ • Processed via scheduler priority lanes │ └──────────────────────────────────────────────────────┘

Structs§

TextStyleInput
Simplified text style for sync MeasureText calls (serde-compatible).

Enums§

AsyncCall
Asynchronous call from JS → Rust. Returns immediately, enqueues work. These are processed on the next frame via the scheduler.
NativeCallback
A callback event dispatched synchronously from Rust → JS. These are the native events that React needs to respond to immediately.
SyncCall
Synchronous call from JS → Rust. Returns immediately. RULE: No mutation allowed. Read-only queries only.
SyncResult
Result of a synchronous call.

Traits§

SyncSafe
Marker trait: types that are safe for the sync path. Sync operations MUST NOT mutate the tree, layout, or native views.

Functions§

appscale_async_call
Asynchronous call from native → Rust. Returns immediately, enqueues work.
appscale_free_string
Free a string returned by appscale_sync_call.
appscale_sync_call
Synchronous call from native → Rust. Blocks, returns JSON string. The caller MUST free the returned string with appscale_free_string().
set_engine_ptr
Initialize the global engine pointer. Must be called once at startup.