Skip to main content

FakeServices

Struct FakeServices 

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

Install with Ui::set_services.

Implementations§

Trait Implementations§

Source§

impl Default for FakeServices

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Services for FakeServices

Source§

fn window_destroyed(&mut self, window: NodeId)

Alerts and file dialogs asked for on the window answer as their cancel would. Those without a parent stay: the fake doesn’t know which window is focused.

Source§

fn clipboard_text(&mut self, reply: Reply<Option<String>>)

Reads the clipboard’s text. Async because GTK and WinUI only read the clipboard asynchronously; platforms that can may reply right away.
Source§

fn set_clipboard_text( &mut self, text: &str, reply: Reply<Result<(), ServiceError>>, )

Writes the clipboard (it can fail: e.g. another process holds it).
Source§

fn alert(&mut self, parent: Option<NodeId>, alert: &Alert, reply: Reply<usize>)

Shows an alert, attached to parent if given (a sheet on macOS) or to the active window. Must not block: reply when the user answers.
Source§

fn open_file( &mut self, parent: Option<NodeId>, request: &OpenFile, reply: Reply<Option<Vec<PathBuf>>>, )

Replies with the chosen paths, or None if cancelled.
Source§

fn save_file( &mut self, parent: Option<NodeId>, request: &SaveFile, reply: Reply<Option<PathBuf>>, )

Source§

fn trash( &mut self, parent: Option<NodeId>, paths: &[PathBuf], reply: Reply<Result<(), ServiceError>>, )

Moves files and folders to the user’s trash, as the platform’s file manager does, so they can be put back from there. Items go one after another; the reply comes once all have gone, or with the first failure, and those before it stay in the trash. Unavailable: the item’s disk has no trash. Cancelled: the user said no where the platform asks first (Windows, when its settings say so).
Source§

fn launch( &mut self, parent: Option<NodeId>, target: &Launch, reply: Reply<Result<(), ServiceError>>, )

Opens a file, folder or URL in the app the platform picks for it, as its file manager would on a double-click. The platform may ask which app when none is set; Cancelled if the user dismissed it, Unavailable if no app opens it. Replies once the platform has handed it over, not when the app has opened it.
Source§

fn notify( &mut self, notification: &Notification, activated: Rc<dyn Fn(String)>, reply: Reply<Result<(), ServiceError>>, )

Shows a notification outside the app’s windows, as the platform shows its apps’, replacing the one with the same id (notification.id is always set). Replies once the platform has it: Cancelled if the user turned the app’s notifications off or said no when the platform asked, Unavailable if there’s nothing to show it (no notification server, a macOS app outside a bundle). When the user clicks it, the platform brings the app forward, as it does for its own apps, and the backend calls activated with its id.
Source§

fn withdraw_notification(&mut self, id: &str)

Takes the notification with this id away, from the screen and the platform’s list. Nothing happens if there’s none.
Source§

fn set_menu( &mut self, window: Option<NodeId>, menu: &MenuBarData, activate: Rc<dyn Fn(u32)>, )

Installs a menu bar: the app’s (window is None), or one window’s own menus, which it shows with the app’s (MenuBarData::merged). Called again whenever the bar changes; an empty bar removes a window’s menus. A window’s menus may arrive before the window is created, and after it’s destroyed. Read more
Source§

fn set_tray( &mut self, tray: Option<&TrayData>, activate: Rc<dyn Fn(u32)>, shown: Rc<dyn Fn(bool)>, )

Shows the app’s icon in the platform’s tray, or takes it away (None). Called again whenever it changes. A click opens its menu (there’s no other click), and the backend calls activate with the id of the item chosen. Call shown whenever whether it’s showing changes: on Linux the tray’s host can come and go, and plain GNOME has none. A platform without a tray keeps the default, which shows nothing.

Auto Trait Implementations§

§

impl !RefUnwindSafe for FakeServices

§

impl !Send for FakeServices

§

impl !Sync for FakeServices

§

impl !UnwindSafe for FakeServices

§

impl Forget for FakeServices

§

impl Freeze for FakeServices
where *const RcInner<RefCell<State>> is !null: Freeze, PhantomData<RcInner<RefCell<State>>>: Freeze,

§

impl Move for FakeServices

§

impl Unpin for FakeServices
where Rc<RefCell<State>>: Unpin,

§

impl UnsafeUnpin for FakeServices
where *const RcInner<RefCell<State>> is !null: UnsafeUnpin, PhantomData<RcInner<RefCell<State>>>: UnsafeUnpin,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.