Skip to main content

Lifecycle

Trait Lifecycle 

Source
pub trait Lifecycle: 'static + Sealed {
    // Required methods
    fn take(&mut self) -> LifecycleCallback;
    fn restore(&mut self, callback: LifecycleCallback);
}
Expand description

A component whose callback the world runs at a structural change.

The trait is what lets the spawn and despawn paths share one runner. It is sealed: the world only knows how to run OnSpawn and OnDespawn, so implementing it elsewhere would not make anything run.

Required Methods§

Source

fn take(&mut self) -> LifecycleCallback

Take the callback out, leaving a placeholder in its place.

Source

fn restore(&mut self, callback: LifecycleCallback)

Put a callback taken by Lifecycle::take back.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§