Skip to main content

ContextApiBuilder

Struct ContextApiBuilder 

Source
pub struct ContextApiBuilder { /* private fields */ }

Implementations§

Source§

impl ContextApiBuilder

Source

pub fn device_context(self, device_context: DeviceContext) -> Self

Examples found in repository?
examples/enveloped_clipboard_monitor.rs (lines 10-16)
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}
Source

pub fn application_context( self, application_context: ApplicationContext, ) -> Self

Examples found in repository?
examples/enveloped_clipboard_monitor.rs (lines 17-21)
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}
Source

pub fn build(self) -> Result<ContextApi, Error>

Examples found in repository?
examples/enveloped_clipboard_monitor.rs (line 22)
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}

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> 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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.