Struct StatusNotifierWatcher

Source
pub struct StatusNotifierWatcher { /* private fields */ }
Expand description

Implementations§

Source§

impl StatusNotifierWatcher

Source

pub async fn create_notifier_host( &self, unique_id: &str, ) -> Result<NotifierHost>

Examples found in repository?
examples/simple.rs (line 10)
6async fn main() -> stray::error::Result<()> {
7    let (_cmd_tx, cmd_rx) = mpsc::channel(10);
8    let tray = StatusNotifierWatcher::new(cmd_rx).await?;
9
10    let mut host_one = tray.create_notifier_host("host_one").await.unwrap();
11    let mut host_two = tray.create_notifier_host("host_two").await.unwrap();
12
13    let one = tokio::spawn(async move {
14        while let Ok(mesage) = host_one.recv().await {
15            println!("Message from host one {:?}", mesage);
16        }
17    });
18
19    let two = tokio::spawn(async move {
20        let mut count = 0;
21        while let Ok(mesage) = host_two.recv().await {
22            count += 1;
23            if count > 5 {
24                break;
25            }
26            println!("Message from host two {:?}", mesage);
27        }
28
29        host_two.destroy().await?;
30        stray::error::Result::<()>::Ok(())
31    });
32
33    let _ = join!(one, two);
34    Ok(())
35}
Source§

impl StatusNotifierWatcher

Source

pub async fn new( cmd_rx: Receiver<NotifierItemCommand>, ) -> Result<StatusNotifierWatcher>

Creates a new system stray and register a StatusNotifierWatcher and StatusNotifierHost on dbus. Once created you can receive StatusNotifierItem. Once created you can start to poll message using the [Stream] implementation.

Examples found in repository?
examples/simple.rs (line 8)
6async fn main() -> stray::error::Result<()> {
7    let (_cmd_tx, cmd_rx) = mpsc::channel(10);
8    let tray = StatusNotifierWatcher::new(cmd_rx).await?;
9
10    let mut host_one = tray.create_notifier_host("host_one").await.unwrap();
11    let mut host_two = tray.create_notifier_host("host_two").await.unwrap();
12
13    let one = tokio::spawn(async move {
14        while let Ok(mesage) = host_one.recv().await {
15            println!("Message from host one {:?}", mesage);
16        }
17    });
18
19    let two = tokio::spawn(async move {
20        let mut count = 0;
21        while let Ok(mesage) = host_two.recv().await {
22            count += 1;
23            if count > 5 {
24                break;
25            }
26            println!("Message from host two {:?}", mesage);
27        }
28
29        host_two.destroy().await?;
30        stray::error::Result::<()>::Ok(())
31    });
32
33    let _ = join!(one, two);
34    Ok(())
35}

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more