pub struct Open<Msg> { /* private fields */ }Expand description
Starts a program beside the application: the desktop’s own opener for an address or a path, or a program named outright. The screen stays where it is and nothing is drawn again.
The answer is optional. With Open::answer a message says whether the program was started;
whether the desktop then really showed the thing is not something a terminal can know, so
OpenOutcome::Opened says the opener was handed the target and no more.
use qframe::prelude::*;
use qframe::runtime::{Open, OpenOutcome};
enum Msg {
SignIn(String),
Opened(OpenOutcome),
}
fn update(msg: Msg) -> Command<Msg> {
match msg {
// The address goes to whatever browser this person uses; the screen never blinks.
Msg::SignIn(address) => Command::open_with(Open::new(address).answer(Msg::Opened)),
Msg::Opened(_) => Command::none(),
}
}Implementations§
Source§impl<Msg: Send + 'static> Open<Msg>
impl<Msg: Send + 'static> Open<Msg>
Sourcepub fn new(target: impl Into<OsString>) -> Self
pub fn new(target: impl Into<OsString>) -> Self
Opens target — an address, a file or a folder — with the opener of this desktop:
xdg-open, open on macOS, start on Windows.
Sourcepub fn program(program: impl Into<OsString>) -> Self
pub fn program(program: impl Into<OsString>) -> Self
Starts program itself instead of the desktop’s opener, the same way: quietly, beside the
application, with nothing drawn again.
Sourcepub fn args(self, args: impl IntoIterator<Item = impl Into<OsString>>) -> Self
pub fn args(self, args: impl IntoIterator<Item = impl Into<OsString>>) -> Self
Adds several arguments, in order.
Sourcepub fn dir(self, dir: impl Into<PathBuf>) -> Self
pub fn dir(self, dir: impl Into<PathBuf>) -> Self
Starts the program in dir instead of the application’s working directory.
Sourcepub fn env(self, key: impl Into<OsString>, value: impl Into<OsString>) -> Self
pub fn env(self, key: impl Into<OsString>, value: impl Into<OsString>) -> Self
Sets an environment variable for the program. The rest of the environment is inherited.
Sourcepub fn answer(
self,
on_open: impl FnOnce(OpenOutcome) -> Msg + Send + 'static,
) -> Self
pub fn answer( self, on_open: impl FnOnce(OpenOutcome) -> Msg + Send + 'static, ) -> Self
Delivers on_open(outcome) once the program has been started, or could not be.
Without it nothing is delivered: an application that has nothing to say about the opening asks for no message.
Auto Trait Implementations§
impl<Msg> !RefUnwindSafe for Open<Msg>
impl<Msg> !Sync for Open<Msg>
impl<Msg> !UnwindSafe for Open<Msg>
impl<Msg> Freeze for Open<Msg>
impl<Msg> Send for Open<Msg>
impl<Msg> Unpin for Open<Msg>
impl<Msg> UnsafeUnpin for Open<Msg>
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more