Skip to main content

Backend

Trait Backend 

Source
pub trait Backend {
    type Handle: Clone;

Show 15 methods // Required methods fn list_apps(&self) -> Result<Vec<AppInfo>>; fn capture( &self, app: &AppInfo, request: &CaptureRequest, ) -> Result<Capture<Self::Handle>>; fn perform_action(&self, element: &Self::Handle, action: &str) -> Result<()>; fn set_value(&self, element: &Self::Handle, value: &str) -> Result<()>; fn click( &self, target: InputTarget<'_>, point: Point, button: MouseButton, count: u32, ) -> Result<()>; fn scroll( &self, target: InputTarget<'_>, point: Point, dx: f64, dy: f64, ) -> Result<()>; fn drag( &self, target: InputTarget<'_>, from: Point, to: Point, ) -> Result<()>; fn type_text(&self, target: InputTarget<'_>, text: &str) -> Result<()>; fn press_key(&self, target: InputTarget<'_>, chord: &KeyChord) -> Result<()>; // Provided methods fn launch_app(&self, app: &AppInfo) -> Result<AppInfo> { ... } fn permissions(&self) -> Permissions { ... } fn request_permissions(&self) -> Permissions { ... } fn value(&self, element: &Self::Handle) -> Result<Option<String>> { ... } fn select_text( &self, element: &Self::Handle, value: &str, range: Range<usize>, ) -> Result<()> { ... } fn insert_text(&self, app: &AppInfo, text: &str) -> Result<bool> { ... }
}
Expand description

OS primitives for observing and driving apps.

All coordinates are screen points with a top-left origin. Methods with default implementations return Error::Unsupported.

Required Associated Types§

Source

type Handle: Clone

Handle to a live accessibility element (e.g. AXUIElement, IUIAutomationElement).

Required Methods§

Source

fn list_apps(&self) -> Result<Vec<AppInfo>>

Running apps plus installed apps the user can launch.

§Errors

Fails if the platform’s process or app registry cannot be read.

Source

fn capture( &self, app: &AppInfo, request: &CaptureRequest, ) -> Result<Capture<Self::Handle>>

Captures the app’s current window.

§Errors

Fails if the app has no usable window or permissions are missing.

Source

fn perform_action(&self, element: &Self::Handle, action: &str) -> Result<()>

Invokes a named accessibility action (as listed in Action::name).

§Errors

Fails if the element is gone or rejects the action.

Source

fn set_value(&self, element: &Self::Handle, value: &str) -> Result<()>

Writes an element’s value.

§Errors

Fails if the value is not settable.

Source

fn click( &self, target: InputTarget<'_>, point: Point, button: MouseButton, count: u32, ) -> Result<()>

Clicks count times at a screen point.

§Errors

Fails if the events cannot be posted.

Source

fn scroll( &self, target: InputTarget<'_>, point: Point, dx: f64, dy: f64, ) -> Result<()>

Scrolls at a screen point by (dx, dy) points; positive dy reveals content below.

§Errors

Fails if the events cannot be posted.

Source

fn drag(&self, target: InputTarget<'_>, from: Point, to: Point) -> Result<()>

Presses the primary button at from, moves to to, and releases.

§Errors

Fails if the events cannot be posted.

Source

fn type_text(&self, target: InputTarget<'_>, text: &str) -> Result<()>

Types literal text.

§Errors

Fails if the events cannot be posted.

Source

fn press_key(&self, target: InputTarget<'_>, chord: &KeyChord) -> Result<()>

Presses and releases a key chord.

§Errors

Fails if the key has no mapping on this platform or events cannot be posted.

Provided Methods§

Source

fn launch_app(&self, app: &AppInfo) -> Result<AppInfo>

Starts app without bringing it to the foreground and returns its running record.

§Errors

Fails if the app cannot be started or does not appear in time.

Source

fn permissions(&self) -> Permissions

Permissions currently held by this process.

Source

fn request_permissions(&self) -> Permissions

Asks the OS to prompt the user for missing permissions, then reports the current state.

Source

fn value(&self, element: &Self::Handle) -> Result<Option<String>>

Reads an element’s full, untruncated value.

§Errors

Fails if the element is gone.

Source

fn select_text( &self, element: &Self::Handle, value: &str, range: Range<usize>, ) -> Result<()>

Selects range (byte offsets into value, the element’s current value). An empty range places the caret.

§Errors

Fails if the element does not support text selection.

Source

fn insert_text(&self, app: &AppInfo, text: &str) -> Result<bool>

Inserts text at the caret of the focused element without synthesizing keystrokes. Returns Ok(false) when the focused element does not support it, so the caller can fall back to Backend::type_text.

§Errors

Fails if insertion was attempted and rejected.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Backend for MacBackend

Available on macOS only.