Skip to main content

Lifecycle

Enum Lifecycle 

Source
pub enum Lifecycle {
    WillLaunch,
    DidLaunch,
    DidBecomeActive,
    WillResignActive,
    WillEnterForeground,
    DidEnterBackground,
    DidReceiveMemoryWarning,
    WillTerminate,
}
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 truly enters the background and can be low on memory, a desktop app essentially cannot — so Lifecycle::is_universal marks the ones every backend delivers, and Toolkit::supports_lifecycle reports per-backend truth.

Rough native mapping:

phaseAppKitUIKitGTKQtAndroidXAML
WillLaunch / DidLaunchapplicationWill/DidFinishLaunchingsamestartup/mountmountonCreatewindow create
DidBecomeActivedidBecomeActivedidBecomeActivenotify::is-activeApplicationActiveonResumeActivated
WillResignActivewillResignActivewillResignActivenotify::is-activeApplicationInactiveonPauseDeactivated
WillEnterForegroundwillEnterForegroundonStart
DidEnterBackgrounddidEnterBackgroundonStop
DidReceiveMemoryWarningdidReceiveMemoryWarningonTrimMemory
WillTerminatewillTerminatewillTerminateshutdownaboutToQuitonDestroywindow close

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.

Implementations§

Source§

impl Lifecycle

Source

pub const ALL: [Lifecycle; 8]

Every phase, in delivery order (launch → run → quit). Handy for logging/registration sweeps.

Source

pub const fn is_universal(self) -> bool

True for phases EVERY backend delivers (launch, activation, termination). The remaining phases (WillEnterForeground, DidEnterBackground, DidReceiveMemoryWarning) are genuine 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.

Source

pub const fn name(self) -> &'static str

A stable, human-readable name (for logs/warnings).

Trait Implementations§

Source§

impl Clone for Lifecycle

Source§

fn clone(&self) -> Lifecycle

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Lifecycle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Lifecycle

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Lifecycle

Source§

fn eq(&self, other: &Lifecycle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Lifecycle

Source§

impl Eq for Lifecycle

Source§

impl StructuralPartialEq for Lifecycle

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Day API ↩ Guides· daybrite.dev