pub struct PermissionRequest {
pub capability: Capability,
pub scope: Scope,
pub reason: String,
pub ttl: Option<Duration>,
}Fields§
§capability: Capability§scope: Scope§reason: String§ttl: Option<Duration>Implementations§
Source§impl PermissionRequest
impl PermissionRequest
Sourcepub fn new(
capability: Capability,
scope: Scope,
reason: impl Into<String>,
) -> Self
pub fn new( capability: Capability, scope: Scope, reason: impl Into<String>, ) -> Self
Examples found in repository?
More examples
examples/clipboard_monitor.rs (lines 20-24)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut api = ContextApi::new()?;
7
8 api.subscribe(SignalType::Clipboard, |signal| {
9 println!(
10 "clipboard changed: type={:?}, bytes={}, source={}, sensitive={}, command={}",
11 signal.content_type,
12 signal.size_bytes,
13 signal.source_app,
14 signal.likely_sensitive,
15 signal.likely_command
16 );
17 })?;
18
19 api.request_permission(
20 PermissionRequest::new(
21 Capability::ReadClipboardContent,
22 Scope::Session,
23 "Show how explicit content access works in the example",
24 )
25 .with_ttl(Duration::from_secs(300)),
26 )?;
27
28 if let Ok(content) = api.read_clipboard_content() {
29 println!("initial clipboard preview: {}", content.redacted_preview());
30 }
31
32 println!("Monitoring clipboard changes. Press Ctrl+C to exit.");
33 api.run_with_signals()?;
34 Ok(())
35}examples/enveloped_clipboard_monitor.rs (lines 25-29)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let mut api = ContextApi::builder()
10 .device_context(DeviceContext {
11 device_id: "desktop:devbox".to_string(),
12 device_name: "devbox".to_string(),
13 platform: Platform::Linux,
14 device_class: DeviceClass::Desktop,
15 os_version: None,
16 })
17 .application_context(ApplicationContext {
18 app_id: "lcsa-demo".to_string(),
19 app_name: "lcsa-demo".to_string(),
20 app_version: Some("0.1.0".to_string()),
21 })
22 .build()?;
23
24 api.request_permission(
25 PermissionRequest::new(
26 Capability::ReadClipboardContent,
27 Scope::Session,
28 "Demonstrate cross-device envelopes plus gated content access",
29 )
30 .with_ttl(Duration::from_secs(300)),
31 )?;
32
33 api.subscribe_enveloped(SignalType::Clipboard, |envelope| {
34 println!(
35 "envelope={} device={} app={} source={:?}",
36 envelope.signal_id,
37 envelope.device.device_id,
38 envelope.application.app_id,
39 envelope.source
40 );
41 })?;
42
43 println!("Monitoring enveloped clipboard signals. Press Ctrl+C to exit.");
44 api.run_with_signals()?;
45 Ok(())
46}Sourcepub fn with_ttl(self, ttl: Duration) -> Self
pub fn with_ttl(self, ttl: Duration) -> Self
Examples found in repository?
examples/clipboard_monitor.rs (line 25)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut api = ContextApi::new()?;
7
8 api.subscribe(SignalType::Clipboard, |signal| {
9 println!(
10 "clipboard changed: type={:?}, bytes={}, source={}, sensitive={}, command={}",
11 signal.content_type,
12 signal.size_bytes,
13 signal.source_app,
14 signal.likely_sensitive,
15 signal.likely_command
16 );
17 })?;
18
19 api.request_permission(
20 PermissionRequest::new(
21 Capability::ReadClipboardContent,
22 Scope::Session,
23 "Show how explicit content access works in the example",
24 )
25 .with_ttl(Duration::from_secs(300)),
26 )?;
27
28 if let Ok(content) = api.read_clipboard_content() {
29 println!("initial clipboard preview: {}", content.redacted_preview());
30 }
31
32 println!("Monitoring clipboard changes. Press Ctrl+C to exit.");
33 api.run_with_signals()?;
34 Ok(())
35}More examples
examples/enveloped_clipboard_monitor.rs (line 30)
8fn main() -> Result<(), Box<dyn std::error::Error>> {
9 let mut api = ContextApi::builder()
10 .device_context(DeviceContext {
11 device_id: "desktop:devbox".to_string(),
12 device_name: "devbox".to_string(),
13 platform: Platform::Linux,
14 device_class: DeviceClass::Desktop,
15 os_version: None,
16 })
17 .application_context(ApplicationContext {
18 app_id: "lcsa-demo".to_string(),
19 app_name: "lcsa-demo".to_string(),
20 app_version: Some("0.1.0".to_string()),
21 })
22 .build()?;
23
24 api.request_permission(
25 PermissionRequest::new(
26 Capability::ReadClipboardContent,
27 Scope::Session,
28 "Demonstrate cross-device envelopes plus gated content access",
29 )
30 .with_ttl(Duration::from_secs(300)),
31 )?;
32
33 api.subscribe_enveloped(SignalType::Clipboard, |envelope| {
34 println!(
35 "envelope={} device={} app={} source={:?}",
36 envelope.signal_id,
37 envelope.device.device_id,
38 envelope.application.app_id,
39 envelope.source
40 );
41 })?;
42
43 println!("Monitoring enveloped clipboard signals. Press Ctrl+C to exit.");
44 api.run_with_signals()?;
45 Ok(())
46}Trait Implementations§
Source§impl Clone for PermissionRequest
impl Clone for PermissionRequest
Source§fn clone(&self) -> PermissionRequest
fn clone(&self) -> PermissionRequest
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PermissionRequest
impl Debug for PermissionRequest
Source§impl PartialEq for PermissionRequest
impl PartialEq for PermissionRequest
impl Eq for PermissionRequest
impl StructuralPartialEq for PermissionRequest
Auto Trait Implementations§
impl Freeze for PermissionRequest
impl RefUnwindSafe for PermissionRequest
impl Send for PermissionRequest
impl Sync for PermissionRequest
impl Unpin for PermissionRequest
impl UnsafeUnpin for PermissionRequest
impl UnwindSafe for PermissionRequest
Blanket Implementations§
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