pub enum Lifecycle {
WillLaunch,
DidLaunch,
DidBecomeActive,
WillResignActive,
WillEnterForeground,
DidEnterBackground,
DidReceiveMemoryWarning,
WillTerminate,
DidExit,
}Expand description
An app-lifecycle phase (docs/lifecycle.md). Each backend maps these onto its OS’s native app /
activity delegate. Some phases only exist on some platforms (a mobile app enters the
background and can be low on memory, a desktop app cannot), so Lifecycle::is_universal
marks the ones every backend delivers, and Toolkit::supports_lifecycle reports per-backend
truth.
Rough native mapping:
| phase | AppKit | UIKit | GTK | Qt | Android | XAML |
|---|---|---|---|---|---|---|
WillLaunch / DidLaunch | applicationWill/DidFinishLaunching | same | startup/mount | mount | onCreate | window create |
DidBecomeActive | didBecomeActive | didBecomeActive | notify::is-active | ApplicationActive | onResume | Activated |
WillResignActive | willResignActive | willResignActive | notify::is-active | ApplicationInactive | onPause | Deactivated |
WillEnterForeground | — | willEnterForeground | — | — | onStart | — |
DidEnterBackground | — | didEnterBackground | — | — | onStop | — |
DidReceiveMemoryWarning | — | didReceiveMemoryWarning | — | — | onTrimMemory | — |
WillTerminate | willTerminate | willTerminate | shutdown | aboutToQuit | onDestroy | window close |
DidExit | after willTerminate | after willTerminate | run returned | exec returned | after onDestroy | loop returned |
Variants§
WillLaunch
Before the window and UI are built: the first thing to run. Set up global state here.
DidLaunch
The UI is mounted and the app is about to start running. Kick off startup work here.
DidBecomeActive
The app came to the foreground and is the active, focused app receiving input.
WillResignActive
The app is about to stop being active (an interruption, app switch, or losing focus).
WillEnterForeground
The app is about to return to the foreground (mobile). Refresh what background invalidated.
DidEnterBackground
The app left the foreground and is no longer visible (mobile). Persist state, release UI work.
DidReceiveMemoryWarning
The system is low on memory (mobile). Drop caches and non-essential memory now.
WillTerminate
The app is about to terminate: the last chance to save. Triggered by the Quit command, the platform’s quit shortcut, or the OS reclaiming the app.
DidExit
The run loop is over and nothing of the app will run after this: the last phase, after
every WillTerminate handler. Day logs its exit line (“Clean exit for …”) once the
handlers have run, so a handler here is the app’s last word before it.
Implementations§
Source§impl Lifecycle
impl Lifecycle
Sourcepub const ALL: [Lifecycle; 9]
pub const ALL: [Lifecycle; 9]
Every phase, in delivery order (launch → run → quit). Handy for logging/registration sweeps.
Sourcepub const fn is_universal(self) -> bool
pub const fn is_universal(self) -> bool
True for phases every backend delivers (launch, activation, termination). The remaining
phases (WillEnterForeground, DidEnterBackground, DidReceiveMemoryWarning) are mobile
concepts and are only delivered by the mobile backends. const so it composes into a
backend’s const fn lifecycle_supported and thus into compile-time guards.