Skip to main content

AppInfo

Struct AppInfo 

Source
#[non_exhaustive]
pub struct AppInfo { pub name: String, pub bundle_id: Option<String>, pub pid: Option<u32>, pub path: Option<PathBuf>, pub is_running: bool, pub is_active: bool, pub window_title: Option<String>, pub needs_restart: bool, }
Expand description

An application that is running or installed.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§name: String

Human-readable name, e.g. TextEdit.

§bundle_id: Option<String>

Platform identifier: a bundle ID on macOS, an AUMID or executable name on Windows, a desktop-file ID on Linux.

§pid: Option<u32>

Process ID, when running.

§path: Option<PathBuf>

Path to the app bundle or executable.

§is_running: bool

Whether the app currently has a process.

§is_active: bool

Whether the app is the frontmost (focused) app.

§window_title: Option<String>

Title of the app’s main window, when the platform reports one. Queries also match it.

§needs_restart: bool

The app is running but does not expose its UI to accessibility, so it cannot be inspected or controlled until it is quit and started again.

Only set on Linux, for browser-engine apps started before desktop accessibility was turned on.

Implementations§

Source§

impl AppInfo

Source

pub fn new(name: impl Into<String>) -> Self

Creates a record for an app with only a name; fill the rest with the builder methods.

Source

pub fn with_bundle_id(self, bundle_id: impl Into<String>) -> Self

Sets the platform identifier.

Source

pub const fn with_pid(self, pid: u32) -> Self

Marks the app as running with pid.

Source

pub fn with_path(self, path: impl Into<PathBuf>) -> Self

Sets the bundle or executable path.

Source

pub const fn with_active(self, active: bool) -> Self

Marks the app as frontmost.

Source

pub const fn with_needs_restart(self, needs_restart: bool) -> Self

Marks the app as running without an accessibility tree (see AppInfo::needs_restart).

Source

pub fn with_window_title(self, title: impl Into<String>) -> Self

Sets the main window title.

Source

pub fn reference(&self) -> &str

The identifier shown to callers: bundle ID when known, otherwise the name.

Examples found in repository?
examples/list_apps.rs (line 16)
6fn main() -> computer_use::Result<()> {
7    let computer = computer_use::Computer::new()?;
8    for app in computer.list_apps()? {
9        let status = match (app.is_running, app.is_active, app.needs_restart) {
10            (true, _, true) => "restart",
11            (true, true, _) => "active",
12            (true, false, _) => "running",
13            _ => "installed",
14        };
15        let pid = app.pid.map(|p| format!(" pid {p}")).unwrap_or_default();
16        println!("{:<9} {} [{}]{pid}", status, app.name, app.reference());
17    }
18    Ok(())
19}
Source

pub fn match_score(&self, query: &str) -> Option<u8>

How well this app matches a user query; None means no match.

Queries may be a name, bundle ID, path, or pid:<n>. Lower scores are better.

Trait Implementations§

Source§

impl Clone for AppInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for AppInfo

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for AppInfo

Source§

impl PartialEq for AppInfo

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AppInfo

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.