#[non_exhaustive]pub struct Permissions {
pub accessibility: bool,
pub screen_recording: bool,
}Expand description
Which OS permissions the current process holds.
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.accessibility: boolAccessibility / UI automation access.
screen_recording: boolScreen capture access.
Implementations§
Source§impl Permissions
impl Permissions
Sourcepub const fn new(accessibility: bool, screen_recording: bool) -> Self
pub const fn new(accessibility: bool, screen_recording: bool) -> Self
Creates a permission report.
Sourcepub const fn all_granted(&self) -> bool
pub const fn all_granted(&self) -> bool
True when nothing is missing.
Examples found in repository?
examples/inspect.rs (line 26)
13fn main() -> ExitCode {
14 use computer_use::{CaptureOptions, Computer};
15
16 let mut args = std::env::args().skip(1);
17 let Some(app) = args.next() else {
18 eprintln!("usage: inspect <app name | bundle id | pid:N> [screenshot.png]");
19 return ExitCode::FAILURE;
20 };
21 let output = args.next();
22
23 let run = || -> computer_use::Result<()> {
24 let mut computer = Computer::new()?;
25 let permissions = computer.permissions();
26 if !permissions.all_granted() {
27 eprintln!("warning: missing permissions: {permissions:?}");
28 }
29 let started = std::time::Instant::now();
30 let state = computer.get_app_state(&app, &CaptureOptions::default())?;
31 println!("{state}");
32 eprintln!("\ncaptured {} elements in {:?}", state.elements.len(), started.elapsed());
33 if let (Some(path), Some(shot)) = (output, &state.screenshot) {
34 std::fs::write(&path, shot.png())?;
35 eprintln!("saved {}x{} screenshot to {path}", shot.width(), shot.height());
36 }
37 Ok(())
38 };
39 match run() {
40 Ok(()) => ExitCode::SUCCESS,
41 Err(e) => {
42 eprintln!("error: {e}");
43 ExitCode::FAILURE
44 }
45 }
46}Trait Implementations§
Source§impl Clone for Permissions
impl Clone for Permissions
impl Copy for Permissions
Source§impl Debug for Permissions
impl Debug for Permissions
impl Eq for Permissions
Source§impl Hash for Permissions
impl Hash for Permissions
Source§impl PartialEq for Permissions
impl PartialEq for Permissions
impl StructuralPartialEq for Permissions
Auto Trait Implementations§
impl Forget for Permissions
impl Freeze for Permissions
impl RefUnwindSafe for Permissions
impl Send for Permissions
impl Sync for Permissions
impl Unpin for Permissions
impl UnsafeUnpin for Permissions
impl UnwindSafe for Permissions
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more