pub struct EngineRuntime { /* private fields */ }Implementations§
Source§impl EngineRuntime
impl EngineRuntime
Sourcepub fn spawn<F>(make: F) -> EngineResult<Self>
pub fn spawn<F>(make: F) -> EngineResult<Self>
Spawn the engine thread and construct the engine on that thread
via make. This is the only correct construction point: the
platform run loop must be initialized on the same thread that
later drives WebKit.
Returns once the engine thread has signaled it is ready.
Sourcepub fn dispatcher(engine: Box<dyn Engine>) -> (Self, MainThreadDispatcher)
pub fn dispatcher(engine: Box<dyn Engine>) -> (Self, MainThreadDispatcher)
Construct a runtime whose engine runs on the caller’'‘s thread.
No internal thread is spawned. The returned MainThreadDispatcher
drives the engine: call MainThreadDispatcher::tick in the
caller’'’s loop to drain one queued job, or [MainThreadDispatcher::run_until]
to block until a stop flag fires.
Use this when the engine is bound to a specific OS thread (e.g.
the macOS Cocoa main thread, where WKWebView must run).
Sourcepub fn with_waker(self, waker: Waker) -> Self
pub fn with_waker(self, waker: Waker) -> Self
Install the Waker the host loop is woken by.
Call before the runtime is shared. Without one the host must poll; with one it can sleep until there is actually work.
Sourcepub fn shutdown(&mut self)
pub fn shutdown(&mut self)
Cleanly shut down: close the channel and join the thread. Idempotent — calling shutdown twice is a no-op.
pub fn open(&self, url: &str) -> EngineResult<PageHandle>
pub fn close(&self, page: PageHandle) -> EngineResult<()>
pub fn enable_webauthn(&self, page: PageHandle) -> EngineResult<()>
pub fn snapshot(&self, page: PageHandle) -> EngineResult<Tree>
Sourcepub fn snapshot_with_console(
&self,
page: PageHandle,
) -> EngineResult<(Tree, Vec<ConsoleEntry>)>
pub fn snapshot_with_console( &self, page: PageHandle, ) -> EngineResult<(Tree, Vec<ConsoleEntry>)>
Snapshot the tree and read the console buffer in a single
main-thread hop. vs_view needs both (the tree, plus the
console entries behind its ? console_error warning); folding
the cheap native console read into the snapshot dispatch avoids
a second round trip on every view. The console read is a buffer
borrow, so it adds no measurable cost.
pub fn act( &self, page: PageHandle, target: ActTarget, action: Action, mode: InputMode, ) -> EngineResult<()>
Sourcepub fn act_and_snapshot(
&self,
page: PageHandle,
target: ActTarget,
action: Action,
mode: InputMode,
) -> EngineResult<Tree>
pub fn act_and_snapshot( &self, page: PageHandle, target: ActTarget, action: Action, mode: InputMode, ) -> EngineResult<Tree>
Perform an action and snapshot the resulting tree in a single
main-thread hop. vs_act always snapshots right after acting, so
folding the two into one dispatch removes a full engine round
trip (~10ms) from every action. The backend’s act already
settles input + flushes rAF before returning, so the snapshot
sees the post-action DOM exactly as the two-call form did.