pub struct StatusNotifierWatcher { /* private fields */ }
Expand description
Wrap the implementation of org.freedesktop.StatusNotifierWatcher and org.freedesktop.StatusNotifierHost.
Implementations§
Source§impl StatusNotifierWatcher
impl StatusNotifierWatcher
Sourcepub async fn create_notifier_host(
&self,
unique_id: &str,
) -> Result<NotifierHost>
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
impl StatusNotifierWatcher
Sourcepub async fn new(
cmd_rx: Receiver<NotifierItemCommand>,
) -> Result<StatusNotifierWatcher>
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§
impl Freeze for StatusNotifierWatcher
impl RefUnwindSafe for StatusNotifierWatcher
impl Send for StatusNotifierWatcher
impl Sync for StatusNotifierWatcher
impl Unpin for StatusNotifierWatcher
impl UnwindSafe for StatusNotifierWatcher
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