Skip to main content

Owner

Struct Owner 

Source
pub struct Owner(/* private fields */);
Expand description

Identifier for an Owner slot in the runtime’s owner map. Generational — disposing an owner invalidates outstanding Owners pointing at the same slot index.

Implementations§

Source§

impl Owner

Source

pub fn new(parent: Option<Owner>) -> Owner

Create a new owner. If parent is None the current top-of-stack owner is used (or the owner becomes a root if the stack is empty).

The new owner inherits its parent’s paused flag — so a sub-component mounted while its containing route is suspended starts paused, and its effects won’t fire until the route resumes.

Source

pub fn detached_root() -> Owner

Create a parentless root owner, ignoring whatever owner is currently on the stack.

Unlike Owner::new(None) — which adopts the current top-of-stack owner as parent — this always produces a detached root. Use it for process-global singletons whose lifetime must not be tied to the (possibly short-lived) owner that happens to be active when the singleton is first touched.

The canonical case is a module that lazily mints an arena-backed handle on first access (e.g. whisker-safe-area): if that first access lands inside a per-route / per-component owner, minting under new(None) would free the handle when that scope disposes, and a later read would hit a disposed node. Minting under a detached_root() (then never disposing it) keeps the handle alive for the whole process — the intended semantics for a singleton.

The returned owner is never auto-disposed; the caller is expected to leak it (i.e. drop the handle without calling dispose) for genuine process-lifetime data.

Source

pub fn with<R>(self, f: impl FnOnce() -> R) -> R

Push self as the current scope, run f, pop back. Reactive primitives (signal(), effect(), computed(), view elements created via render!) allocated inside f will belong to this owner.

Source

pub fn dispose(self)

Dispose self, freeing all its descendants, nodes, and running its cleanup callbacks.

Recursive — disposes children first, then this owner. Safe to call even if the owner has already been disposed (no-op).

Source

pub fn pause(self)

Pause self (and its descendants): effects and computeds whose scope is the paused subtree skip flush. Their scheduled re-runs land on the runtime’s deferred list until Owner::resume drains them back.

Idempotent — pausing an already-paused owner is a no-op. The cascade walks the children tree breadth-first; new descendants created while paused inherit the flag via Owner::new.

Used by StackLayout to freeze back-stack entries that are mounted-but-off-screen, matching iOS UINavigationController / Android Fragment back-stack semantics: state survives but no CPU is spent on signal-driven re-renders behind the top route.

Source

pub fn resume(self)

Resume self (and its descendants): clear the paused flag and move any of its deferred effects back onto the pending queue so they fire on the next flush.

Idempotent. Iterates super::runtime::ReactiveRuntime::deferred and re-queues every node whose owner is no longer paused — including descendants resumed by this cascade, and any deferred node whose owner happens to have been unpaused by an earlier call.

Source

pub fn is_paused(self) -> bool

Whether self is currently paused. Mainly for tests; production code should drive pause / resume from the lifecycle layer and not branch on the flag directly.

Trait Implementations§

Source§

impl Clone for Owner

Source§

fn clone(&self) -> Owner

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 Copy for Owner

Source§

impl Debug for Owner

Source§

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

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

impl Default for Owner

Source§

fn default() -> Owner

Returns the “default value” for a type. Read more
Source§

impl Eq for Owner

Source§

impl From<KeyData> for Owner

Source§

fn from(k: KeyData) -> Self

Converts to this type from the input type.
Source§

impl Hash for Owner

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 Key for Owner

Source§

fn data(&self) -> KeyData

Gets the KeyData stored in this key. Read more
Source§

fn null() -> Self

Creates a new key that is always invalid and distinct from any non-null key. A null key can only be created through this method (or default initialization of keys made with new_key_type!, which calls this method). Read more
Source§

fn is_null(&self) -> bool

Checks if a key is null. There is only a single null key, that is a.is_null() && b.is_null() implies a == b. Read more
Source§

impl Ord for Owner

Source§

fn cmp(&self, other: &Owner) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Owner

Source§

fn eq(&self, other: &Owner) -> 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 PartialOrd for Owner

Source§

fn partial_cmp(&self, other: &Owner) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Owner

Auto Trait Implementations§

§

impl Freeze for Owner

§

impl RefUnwindSafe for Owner

§

impl Send for Owner

§

impl Sync for Owner

§

impl Unpin for Owner

§

impl UnsafeUnpin for Owner

§

impl UnwindSafe for Owner

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.