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§
Required Methods§
Sourcefn list_apps(&self) -> Result<Vec<AppInfo>>
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.
Sourcefn capture(
&self,
app: &AppInfo,
request: &CaptureRequest,
) -> Result<Capture<Self::Handle>>
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.
Sourcefn perform_action(&self, element: &Self::Handle, action: &str) -> Result<()>
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.
Sourcefn click(
&self,
target: InputTarget<'_>,
point: Point,
button: MouseButton,
count: u32,
) -> Result<()>
fn click( &self, target: InputTarget<'_>, point: Point, button: MouseButton, count: u32, ) -> Result<()>
Sourcefn scroll(
&self,
target: InputTarget<'_>,
point: Point,
dx: f64,
dy: f64,
) -> Result<()>
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.
Sourcefn drag(&self, target: InputTarget<'_>, from: Point, to: Point) -> Result<()>
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.
Provided Methods§
Sourcefn launch_app(&self, app: &AppInfo) -> Result<AppInfo>
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.
Sourcefn permissions(&self) -> Permissions
fn permissions(&self) -> Permissions
Permissions currently held by this process.
Sourcefn request_permissions(&self) -> Permissions
fn request_permissions(&self) -> Permissions
Asks the OS to prompt the user for missing permissions, then reports the current state.
Sourcefn select_text(
&self,
element: &Self::Handle,
value: &str,
range: Range<usize>,
) -> Result<()>
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.
Sourcefn insert_text(&self, app: &AppInfo, text: &str) -> Result<bool>
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".