pub struct Engine { /* private fields */ }Expand description
The Engine is the central coordinator. One Engine instance per application.
Implementations§
Source§impl Engine
impl Engine
Sourcepub fn new(platform: Arc<dyn PlatformBridge>) -> Self
pub fn new(platform: Arc<dyn PlatformBridge>) -> Self
Create a new Engine with the given platform bridge.
Sourcepub fn apply_commit(&mut self, batch: &IrBatch) -> Result<(), EngineError>
pub fn apply_commit(&mut self, batch: &IrBatch) -> Result<(), EngineError>
Process a batch of IR commands from the reconciler. This is the main entry point — called after every React commit.
The flow:
- Decode IR commands (create/update/delete/move nodes)
- Apply to shadow tree + mark dirty
- Recompute layout ONLY for dirty subtrees (Taffy)
- Diff against previous layout
- Issue platform bridge calls (mount phase)
Sourcepub fn enqueue_commit(&self, batch: IrBatch, priority: Priority)
pub fn enqueue_commit(&self, batch: IrBatch, priority: Priority)
Enqueue a batch via the scheduler (called from JS via JSI). The scheduler handles priority ordering and frame coalescing.
Sourcepub fn process_frame(&mut self) -> Result<(), EngineError>
pub fn process_frame(&mut self) -> Result<(), EngineError>
Process all pending scheduled work for this frame. Called by the platform’s vsync/display-link callback.
Handle a navigation action.
Get the navigator (for DevTools inspection).
Sourcepub fn focus_manager(&mut self) -> &mut FocusManager
pub fn focus_manager(&mut self) -> &mut FocusManager
Get the focus manager.
Sourcepub fn scheduler_stats(&self) -> FrameStats
pub fn scheduler_stats(&self) -> FrameStats
Get scheduler stats (for DevTools).
Sourcepub fn handle_event(&mut self, event: InputEvent) -> EventResult
pub fn handle_event(&mut self, event: InputEvent) -> EventResult
Handle a native input event. Called by the platform bridge when the OS delivers touch/mouse/keyboard events.
Sourcepub fn handle_sync(&self, call: &SyncCall) -> SyncResult
pub fn handle_sync(&self, call: &SyncCall) -> SyncResult
Handle a synchronous call from JS.
This takes &self — compile-time guarantee that no mutation happens.
RULE: No UI mutation allowed on the sync path.
Sourcepub fn handle_async(&mut self, call: AsyncCall)
pub fn handle_async(&mut self, call: AsyncCall)
Handle an asynchronous call from JS.
This takes &mut self — mutations are allowed.
Sourcepub fn tree(&self) -> &ShadowTree
pub fn tree(&self) -> &ShadowTree
Get the shadow tree (for DevTools inspection).
Sourcepub fn layout(&self) -> &LayoutEngine
pub fn layout(&self) -> &LayoutEngine
Get the layout engine (for DevTools layout overlay).