#[non_exhaustive]pub enum Termination {
Terminate,
Hangup,
}Expand description
Why the system, rather than the user, is ending the application.
On Unix the terminal Runtime catches SIGTERM, SIGINT and SIGHUP for
as long as it runs, and a Harness simulates them with
Harness::terminate. The application hears the cause through
App::terminating, which is how it tells “the system is ending
us” from “the user asked to quit” (App::before_quit).
Whatever the application answers, the run ends in bounded time:
- Answering
Nonequits at once. - A message keeps the application running while it finishes, e.g. saves and returns
Command::quit. AfterTermination::gracethe runtime quits without it. - A second
SIGTERMorSIGINTends the run at once. When the application does not return to the loop within a second after that, or after its grace, the runtime restores the terminal itself and the process ends by the signal, as it would have without the framework.
Every quit restores the terminal (raw mode off, the normal screen, the cursor) as long as the terminal still exists; after a hangup nothing is written to it.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Terminate
SIGTERM, or SIGINT from kill -INT: another program or the system (a service
manager, a shutdown, kill) asks the application to end. The terminal is still there, so
the application may save and quit, and it may even ask the user something, within the
grace. By default the application answers as for a quit the user asked for, with
App::before_quit.
Inside the application ctrl c is a key, not this signal: raw mode turns the terminal’s
interrupt key off.
Hangup
SIGHUP: the terminal went away, because the SSH connection dropped, the terminal
window or the tmux pane closed. Nobody can answer a question any more and nothing is
drawn after it, so the application gets one chance to save, without a dialog. By default
it quits at once.
A hangup that repeats (the shell forwards its own and the system sends another when the
shell ends) changes nothing. A SIGHUP sent by hand while the terminal is still there is
heard the same way, and the terminal is restored on the way out.
Implementations§
Source§impl Termination
impl Termination
Sourcepub const fn grace(self) -> Duration
pub const fn grace(self) -> Duration
How long the application has, after this cause, to quit on its own before the runtime
quits without it: five seconds after Termination::Terminate, three after
Termination::Hangup. A hangup during a pending terminate shortens what is left to
the hangup’s grace.
use std::time::Duration;
use qframe::runtime::Termination;
assert_eq!(Termination::Terminate.grace(), Duration::from_secs(5));
assert_eq!(Termination::Hangup.grace(), Duration::from_secs(3));Trait Implementations§
Source§impl Clone for Termination
impl Clone for Termination
Source§fn clone(&self) -> Termination
fn clone(&self) -> Termination
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for Termination
Source§impl Debug for Termination
impl Debug for Termination
impl Eq for Termination
Source§impl Hash for Termination
impl Hash for Termination
Source§impl PartialEq for Termination
impl PartialEq for Termination
impl StructuralPartialEq for Termination
Auto Trait Implementations§
impl Freeze for Termination
impl RefUnwindSafe for Termination
impl Send for Termination
impl Sync for Termination
impl Unpin for Termination
impl UnsafeUnpin for Termination
impl UnwindSafe for Termination
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,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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