pub struct Os { /* private fields */ }Expand description
The operating system’s windows and services, for the application’s handlers.
App::run gives it to the setup closure, which puts it
in the router’s state, so a handler reaches it as state.os. A test gives
the handlers testing::FakeOs::os instead, with the
testing feature.
Implementations§
Source§impl Os
impl Os
Sourcepub fn launches(&self) -> Launches
pub fn launches(&self) -> Launches
The launches of the application that start while it runs.
A start of the application while this copy runs hands its command
line and working directory over and exits, and the copy that runs
brings a window forward. On macOS a file or a link the person opens
with the application, which the system hands the copy running
rather than starting another, arrives here too, with each file as
its path and each link as its text in Launch::args. Each
Launches gets the launches handed over after it was made, so a
setup that takes one before it returns the router misses none.
Sourcepub async fn notify(
&self,
notification: Notification,
) -> Result<Notified, Error>
pub async fn notify( &self, notification: Notification, ) -> Result<Notified, Error>
Shows notification among the system’s notifications.
The returned Notified tells whether the person clicked it. On
macOS, the notification comes from the application installed with
the identifier App::new names; a run outside
such a bundle shows it under another application’s name.
§Errors
Fails with ErrorKind::Notification
when the system does not show it, as on Linux without a notification
server.
Sourcepub async fn shortcut(&self, shortcut: Shortcut) -> Result<Presses, Error>
pub async fn shortcut(&self, shortcut: Shortcut) -> Result<Presses, Error>
Registers shortcut for the rest of the run, so the application
hears it while another application has focus.
Each call returns its own Presses of the presses and releases
after it, and a shortcut asked for again is not registered twice. On
Linux, the shortcut is grabbed from the X server, so a Wayland session
delivers it only while an X11 window has focus, and none at all
without Xwayland, where registering still returns Ok.
§Errors
Fails with ErrorKind::Shortcut when
the system does not register it, as when another application holds
it, and when the application is closing.
Sourcepub async fn tray(&self, tray: Tray) -> Result<(), Error>
pub async fn tray(&self, tray: Tray) -> Result<(), Error>
Shows tray in the system tray, in place of the tray shown before.
While a tray is shown, closing the last window leaves the application running, and the tray’s Quit item ends it.
§Errors
Fails with ErrorKind::Tray when the
tray’s icon is not a PNG or the system has no tray, and when the
application is closing.
Puts menus in the menu bar, in place of the menus put there before.
On macOS they go between the Edit and Window menus of the
application’s menu bar, and on Linux in a bar at the top of every
window, opened then or later. Windows shows no menu bar of
this crate’s, since muda puts one in a window only through an
unsafe call, which this crate forbids; there the menus are
recorded and nothing is shown.
§Errors
Fails when the application is closing.
Sourcepub fn badge(&self, count: u32) -> Result<(), Error>
pub fn badge(&self, count: u32) -> Result<(), Error>
Shows count on the application’s icon, or clears it at 0.
macOS writes the number on the Dock icon. Linux sets it on the
launcher entry of <program>.desktop, the desktop file of the
packages cargo-packager builds, which Ubuntu’s dock shows. Windows
puts a red dot on each window’s taskbar button, since a button has
no room for a number.
§Errors
Fails when the application is closing.
Sourcepub fn dialog(&self) -> Dialog
pub fn dialog(&self) -> Dialog
A file dialog, to be given a title and filters before it is shown.
Sourcepub async fn tell(&self, message: Message)
pub async fn tell(&self, message: Message)
Shows message in the system’s message box, with an OK button,
and waits for the person to close it.
Sourcepub async fn confirm(&self, message: Message) -> bool
pub async fn confirm(&self, message: Message) -> bool
Shows message with OK and Cancel buttons, and returns whether the
person chose OK. Closing the box counts as Cancel.
Sourcepub async fn ask(&self, message: Message) -> Answer
pub async fn ask(&self, message: Message) -> Answer
Shows message with Yes, No, and Cancel buttons, and returns the
one the person chose. Closing the box counts as Cancel.
Sourcepub fn autostart(&self) -> Autostart<'_>
pub fn autostart(&self) -> Autostart<'_>
Whether the system starts the application when the person logs in.
Sourcepub fn open_external(&self, url: &SafeUrl) -> Result<(), Error>
pub fn open_external(&self, url: &SafeUrl) -> Result<(), Error>
Opens url in the person’s web browser, or their mail program for a
mailto: URL.
§Errors
Fails with ErrorKind::NotExternal
when url names no scheme, as /notes does, since the system would
open such a path as a file, and fails when the system cannot open it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Os
impl RefUnwindSafe for Os
impl Send for Os
impl Sync for Os
impl Unpin for Os
impl UnsafeUnpin for Os
impl UnwindSafe for Os
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.