#[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>,
}Expand description
An application that is running or installed.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: StringHuman-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: boolWhether the app currently has a process.
is_active: boolWhether 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.
Implementations§
Source§impl AppInfo
impl AppInfo
Sourcepub fn new(name: impl Into<String>) -> Self
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.
Sourcepub fn with_bundle_id(self, bundle_id: impl Into<String>) -> Self
pub fn with_bundle_id(self, bundle_id: impl Into<String>) -> Self
Sets the platform identifier.
Sourcepub const fn with_active(self, active: bool) -> Self
pub const fn with_active(self, active: bool) -> Self
Marks the app as frontmost.
Sourcepub fn with_window_title(self, title: impl Into<String>) -> Self
pub fn with_window_title(self, title: impl Into<String>) -> Self
Sets the main window title.
Sourcepub fn reference(&self) -> &str
pub fn reference(&self) -> &str
The identifier shown to callers: bundle ID when known, otherwise the name.
Examples found in repository?
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) {
10 (true, true) => "active",
11 (true, false) => "running",
12 _ => "installed",
13 };
14 let pid = app.pid.map(|p| format!(" pid {p}")).unwrap_or_default();
15 println!("{:<9} {} [{}]{pid}", status, app.name, app.reference());
16 }
17 Ok(())
18}Sourcepub fn match_score(&self, query: &str) -> Option<u8>
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.