pub trait Engine {
Show 28 methods
// Required methods
fn open(&mut self, url: &str) -> EngineResult<PageHandle>;
fn navigate(&mut self, page: PageHandle, url: &str) -> EngineResult<()>;
fn enable_webauthn(&mut self, page: PageHandle) -> EngineResult<()>;
fn close(&mut self, page: PageHandle) -> EngineResult<()>;
fn snapshot(&mut self, page: PageHandle) -> EngineResult<Tree>;
fn act(
&mut self,
page: PageHandle,
target: ActTarget,
action: Action,
mode: InputMode,
) -> EngineResult<()>;
fn wait(
&mut self,
page: PageHandle,
cond: WaitCondition,
budget: Duration,
) -> EngineResult<()>;
fn capture(
&mut self,
page: PageHandle,
scope: CaptureScope,
) -> EngineResult<PathBuf>;
fn layout(
&mut self,
page: PageHandle,
refs: &[Ref],
) -> EngineResult<Vec<LayoutBox>>;
fn set_viewport(
&mut self,
page: PageHandle,
viewport: Viewport,
) -> EngineResult<()>;
fn save_auth(&mut self, page: PageHandle) -> EngineResult<AuthBlob>;
fn load_auth(
&mut self,
page: PageHandle,
blob: &AuthBlob,
) -> EngineResult<()>;
fn capabilities(&self) -> EngineCapabilities;
// Provided methods
fn capture_live(
&mut self,
page: PageHandle,
_max_width: u32,
) -> EngineResult<PathBuf> { ... }
fn record_begin(
&mut self,
_page: PageHandle,
_tx: Sender<RecFrame>,
_fps: u32,
_max_width: u32,
) -> EngineResult<()> { ... }
fn record_end(&mut self, _page: PageHandle) -> EngineResult<()> { ... }
fn console_entries(
&mut self,
_page: PageHandle,
) -> EngineResult<Vec<ConsoleEntry>> { ... }
fn network_entries(
&mut self,
_page: PageHandle,
) -> EngineResult<Vec<NetworkEntry>> { ... }
fn request_detail(
&mut self,
_page: PageHandle,
_seq: u64,
) -> EngineResult<Option<RequestDetail>> { ... }
fn eval_js(
&mut self,
_page: PageHandle,
_expr: &str,
) -> EngineResult<EvalResult> { ... }
fn storage(
&mut self,
_page: PageHandle,
_scope: StorageScope,
) -> EngineResult<Vec<StorageEntry>> { ... }
fn cookie_events(
&mut self,
_page: PageHandle,
) -> EngineResult<Vec<CookieEvent>> { ... }
fn type_text(
&mut self,
_page: PageHandle,
_text: &str,
_mode: InputMode,
) -> EngineResult<()> { ... }
fn cursor_op(
&mut self,
_page: PageHandle,
_op: CursorOp,
_mode: InputMode,
) -> EngineResult<()> { ... }
fn scripts(&mut self, _page: PageHandle) -> EngineResult<Vec<ScriptEntry>> { ... }
fn script_source(
&mut self,
_page: PageHandle,
_seq: u64,
) -> EngineResult<Option<ScriptSource>> { ... }
fn dom(
&mut self,
_page: PageHandle,
_r: Ref,
_extra_props: &[String],
) -> EngineResult<Option<DomDetail>> { ... }
fn performance(
&mut self,
_page: PageHandle,
) -> EngineResult<PerformanceMetrics> { ... }
}Expand description
The browser engine, as the daemon sees it.
All methods are synchronous from the daemon’s perspective. The
runtime layer dispatches calls onto a dedicated
thread that owns the platform run loop; implementations should
assume they are running on that thread.
Required Methods§
Sourcefn open(&mut self, url: &str) -> EngineResult<PageHandle>
fn open(&mut self, url: &str) -> EngineResult<PageHandle>
Open a fresh page navigated to url.
Navigate an existing page to url in place, reusing its
web view (and web-content process) instead of creating a new
one. The page handle is unchanged; the document is replaced, so
callers must re-baseline (all refs are fresh). Much cheaper than
open for successive navigations.
Sourcefn enable_webauthn(&mut self, page: PageHandle) -> EngineResult<()>
fn enable_webauthn(&mut self, page: PageHandle) -> EngineResult<()>
Install a virtual WebAuthn authenticator on page: a pure-JS
software authenticator that overrides navigator.credentials
so passkey registration and login work headlessly, with no
platform authenticator and no automation protocol. Applies to
the current document and (where the backend supports it) to
subsequent navigations in the same page.
Sourcefn close(&mut self, page: PageHandle) -> EngineResult<()>
fn close(&mut self, page: PageHandle) -> EngineResult<()>
Close a page. Idempotent — closing a closed page is a no-op.
Sourcefn snapshot(&mut self, page: PageHandle) -> EngineResult<Tree>
fn snapshot(&mut self, page: PageHandle) -> EngineResult<Tree>
Snapshot the a11y tree at page.
Sourcefn act(
&mut self,
page: PageHandle,
target: ActTarget,
action: Action,
mode: InputMode,
) -> EngineResult<()>
fn act( &mut self, page: PageHandle, target: ActTarget, action: Action, mode: InputMode, ) -> EngineResult<()>
Perform action on target at page.
Sourcefn wait(
&mut self,
page: PageHandle,
cond: WaitCondition,
budget: Duration,
) -> EngineResult<()>
fn wait( &mut self, page: PageHandle, cond: WaitCondition, budget: Duration, ) -> EngineResult<()>
Wait for cond at page until satisfied or budget elapses.
Sourcefn capture(
&mut self,
page: PageHandle,
scope: CaptureScope,
) -> EngineResult<PathBuf>
fn capture( &mut self, page: PageHandle, scope: CaptureScope, ) -> EngineResult<PathBuf>
Take a screenshot. Returns the path on disk where the image was written.
Sourcefn layout(
&mut self,
page: PageHandle,
refs: &[Ref],
) -> EngineResult<Vec<LayoutBox>>
fn layout( &mut self, page: PageHandle, refs: &[Ref], ) -> EngineResult<Vec<LayoutBox>>
Compute layout boxes for refs at page.
Sourcefn set_viewport(
&mut self,
page: PageHandle,
viewport: Viewport,
) -> EngineResult<()>
fn set_viewport( &mut self, page: PageHandle, viewport: Viewport, ) -> EngineResult<()>
Set the viewport at page. Triggers a re-baseline for the next
snapshot.
Sourcefn save_auth(&mut self, page: PageHandle) -> EngineResult<AuthBlob>
fn save_auth(&mut self, page: PageHandle) -> EngineResult<AuthBlob>
Snapshot cookies/storage for page as an opaque AuthBlob.
Sourcefn load_auth(&mut self, page: PageHandle, blob: &AuthBlob) -> EngineResult<()>
fn load_auth(&mut self, page: PageHandle, blob: &AuthBlob) -> EngineResult<()>
Apply a previously saved AuthBlob to page.
Sourcefn capabilities(&self) -> EngineCapabilities
fn capabilities(&self) -> EngineCapabilities
Capabilities the daemon should advertise for this engine.
Provided Methods§
Sourcefn capture_live(
&mut self,
page: PageHandle,
_max_width: u32,
) -> EngineResult<PathBuf>
fn capture_live( &mut self, page: PageHandle, _max_width: u32, ) -> EngineResult<PathBuf>
Capture a live frame (watch / record) at a reduced width
(max_width px, 0 = full resolution). Cheaper to produce and
encode than a full-resolution screenshot. The default delegates
to Self::capture; backends that can render a smaller snapshot
override it.
Sourcefn record_begin(
&mut self,
_page: PageHandle,
_tx: Sender<RecFrame>,
_fps: u32,
_max_width: u32,
) -> EngineResult<()>
fn record_begin( &mut self, _page: PageHandle, _tx: Sender<RecFrame>, _fps: u32, _max_width: u32, ) -> EngineResult<()>
Begin streaming recording frames for page. While active, the
backend captures a frame at each input step (mouse move,
keystroke, click) and sends it on tx with the cursor position,
so the recorder composites a pointer and encodes smooth motion
without a poller racing the automation. max_width downscales
each frame (0 = full resolution). The default is unsupported so
the daemon can fall back to time-based polling.
Sourcefn record_end(&mut self, _page: PageHandle) -> EngineResult<()>
fn record_end(&mut self, _page: PageHandle) -> EngineResult<()>
Stop streaming recording frames for page (drops the sender so
the recorder’s drain loop ends). Idempotent.
Sourcefn console_entries(
&mut self,
_page: PageHandle,
) -> EngineResult<Vec<ConsoleEntry>>
fn console_entries( &mut self, _page: PageHandle, ) -> EngineResult<Vec<ConsoleEntry>>
Snapshot the always-captured console ring buffer for page.
Default impl returns empty (engines without console capture).
Sourcefn network_entries(
&mut self,
_page: PageHandle,
) -> EngineResult<Vec<NetworkEntry>>
fn network_entries( &mut self, _page: PageHandle, ) -> EngineResult<Vec<NetworkEntry>>
Snapshot the always-captured network ring buffer for page.
Default impl returns empty (engines without network capture).
Sourcefn request_detail(
&mut self,
_page: PageHandle,
_seq: u64,
) -> EngineResult<Option<RequestDetail>>
fn request_detail( &mut self, _page: PageHandle, _seq: u64, ) -> EngineResult<Option<RequestDetail>>
Look up the full detail (headers + bodies) for a single
captured network request. Returns None if the seq isn’t in
the buffer. Default impl returns None.
Sourcefn eval_js(
&mut self,
_page: PageHandle,
_expr: &str,
) -> EngineResult<EvalResult>
fn eval_js( &mut self, _page: PageHandle, _expr: &str, ) -> EngineResult<EvalResult>
Evaluate expr in main world. Default impl returns
EvalResult::Thrown { kind: "NotImplemented", ... }.
Sourcefn storage(
&mut self,
_page: PageHandle,
_scope: StorageScope,
) -> EngineResult<Vec<StorageEntry>>
fn storage( &mut self, _page: PageHandle, _scope: StorageScope, ) -> EngineResult<Vec<StorageEntry>>
List storage entries for the requested scope.
List cookie store ADD/REMOVE events observed since the page
opened. Engines without a cookie-changed observer (Windows, the
stub) return an empty vec or ENGINE_UNSUPPORTED via their
capability flag.
Sourcefn type_text(
&mut self,
_page: PageHandle,
_text: &str,
_mode: InputMode,
) -> EngineResult<()>
fn type_text( &mut self, _page: PageHandle, _text: &str, _mode: InputMode, ) -> EngineResult<()>
Trusted keyboard typing into the focused element. Sends real
per-character key events (KeyDown/KeyUp) so the page sees
isTrusted=true keydown → beforeinput → input, which
rich-text editors (DraftJS/ProseMirror/contenteditable) and
framework-controlled inputs require — the prototype-setter
fill path bypasses their change pipeline. The caller places
the caret first (e.g. vs_click_at). Backends without native
keyboard dispatch fall through to ENGINE_UNSUPPORTED.
Sourcefn cursor_op(
&mut self,
_page: PageHandle,
_op: CursorOp,
_mode: InputMode,
) -> EngineResult<()>
fn cursor_op( &mut self, _page: PageHandle, _op: CursorOp, _mode: InputMode, ) -> EngineResult<()>
Coordinate-addressed cursor operation. Backends that don’t
implement native input dispatch fall through to the default
ENGINE_UNSUPPORTED here; agents see ! ENGINE_UNSUPPORTED
on the wire and can switch to ref-based vs act instead.
Sourcefn scripts(&mut self, _page: PageHandle) -> EngineResult<Vec<ScriptEntry>>
fn scripts(&mut self, _page: PageHandle) -> EngineResult<Vec<ScriptEntry>>
List scripts loaded by the page.
Sourcefn script_source(
&mut self,
_page: PageHandle,
_seq: u64,
) -> EngineResult<Option<ScriptSource>>
fn script_source( &mut self, _page: PageHandle, _seq: u64, ) -> EngineResult<Option<ScriptSource>>
Source of one script by seq. Returns None if the seq isn’t
in the script registry.
Sourcefn dom(
&mut self,
_page: PageHandle,
_r: Ref,
_extra_props: &[String],
) -> EngineResult<Option<DomDetail>>
fn dom( &mut self, _page: PageHandle, _r: Ref, _extra_props: &[String], ) -> EngineResult<Option<DomDetail>>
Outer HTML + computed styles for a ref. Caller-requested
computed properties land in extra_props; the engine merges
them with its default property set. Returns None for unknown
refs.
Sourcefn performance(&mut self, _page: PageHandle) -> EngineResult<PerformanceMetrics>
fn performance(&mut self, _page: PageHandle) -> EngineResult<PerformanceMetrics>
Web Vitals + heap + DOM stats. Returns zero-filled defaults if the engine can’t measure them.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".