Struct ksni::TrayService
source · pub struct TrayService<T> { /* private fields */ }
Expand description
Service of the tray
Implementations§
source§impl<T: Tray + 'static> TrayService<T>
impl<T: Tray + 'static> TrayService<T>
sourcepub fn new(tray: T) -> Self
pub fn new(tray: T) -> Self
Create a new service
Examples found in repository?
examples/example.rs (lines 94-97)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
fn main() {
let service = ksni::TrayService::new(MyTray {
selected_option: 0,
checked: false,
});
let handle = service.handle();
service.spawn();
std::thread::sleep(std::time::Duration::from_secs(5));
// We can modify the handle
handle.update(|tray: &mut MyTray| {
tray.checked = true;
});
// Run forever
loop {
std::thread::park();
}
}
sourcepub fn handle(&self) -> Handle<T>
pub fn handle(&self) -> Handle<T>
Get a handle of the tray
Examples found in repository?
examples/example.rs (line 98)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
fn main() {
let service = ksni::TrayService::new(MyTray {
selected_option: 0,
checked: false,
});
let handle = service.handle();
service.spawn();
std::thread::sleep(std::time::Duration::from_secs(5));
// We can modify the handle
handle.update(|tray: &mut MyTray| {
tray.checked = true;
});
// Run forever
loop {
std::thread::park();
}
}
sourcepub fn run_without_dbus_name(self) -> Result<(), Error>
pub fn run_without_dbus_name(self) -> Result<(), Error>
Run the service in current thread, but not register new dbus name
Which is required for some sandboxed environments (flatpak) https://chromium-review.googlesource.com/c/chromium/src/+/4179380
sourcepub fn spawn(self)where
T: Send,
pub fn spawn(self)where
T: Send,
Run the service in a new thread
Examples found in repository?
examples/example.rs (line 99)
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
fn main() {
let service = ksni::TrayService::new(MyTray {
selected_option: 0,
checked: false,
});
let handle = service.handle();
service.spawn();
std::thread::sleep(std::time::Duration::from_secs(5));
// We can modify the handle
handle.update(|tray: &mut MyTray| {
tray.checked = true;
});
// Run forever
loop {
std::thread::park();
}
}
sourcepub fn spawn_without_dbus_name(self)where
T: Send,
pub fn spawn_without_dbus_name(self)where
T: Send,
Run the service in a new thread, but not register new dbus name
Which is required for some sandboxed environments (flatpak) https://chromium-review.googlesource.com/c/chromium/src/+/4179380
Auto Trait Implementations§
impl<T> Freeze for TrayService<T>
impl<T> RefUnwindSafe for TrayService<T>
impl<T> Send for TrayService<T>where
T: Send,
impl<T> Sync for TrayService<T>where
T: Send,
impl<T> Unpin for TrayService<T>
impl<T> UnwindSafe for TrayService<T>
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