pub struct OwnerHandle(/* private fields */);Expand description
Weak access to an owner’s lifecycle. Safe to retain after disposal.
Implementations§
Source§impl OwnerHandle
impl OwnerHandle
Sourcepub fn guarded<A, R, F: FnMut(A) -> R>(
&self,
callback: F,
) -> impl FnMut(A) -> Option<R> + use<A, R, F>
pub fn guarded<A, R, F: FnMut(A) -> R>( &self, callback: F, ) -> impl FnMut(A) -> Option<R> + use<A, R, F>
Wrap a callback with a weak lifetime check. Late external callbacks return
None after disposal (or before activation) instead of publishing state.
The callback’s own captures still obey ordinary Rust ownership rules.
Sourcepub fn provide<K: ContextKey>(
&self,
value: K::Value,
) -> Result<(), ContextError>
pub fn provide<K: ContextKey>( &self, value: K::Value, ) -> Result<(), ContextError>
Supply a value once on this owner. Descendants resolve the nearest key. This is not reactive registration: supply a signal for changing state.
Sourcepub fn context<K: ContextKey>(&self) -> Option<Rc<K::Value>>
pub fn context<K: ContextKey>(&self) -> Option<Rc<K::Value>>
Find the nearest live provider, including this owner. Missing/disposed
context returns None. Lookup is untracked and does not keep owners alive.
An obtained Rc can outlive the provider like any ordinary Rust value;
disposal prevents further lookup and releases the owner’s reference.
Sourcepub fn is_child_of(&self, parent: &Self) -> bool
pub fn is_child_of(&self, parent: &Self) -> bool
Whether this is an immediate child of the given lifetime.
pub fn is_active(&self) -> bool
pub fn is_disposed(&self) -> bool
Sourcepub fn on_activate(&self, callback: impl FnOnce() + 'static) -> Registration
pub fn on_activate(&self, callback: impl FnOnce() + 'static) -> Registration
Run on activation (immediately if active). Does not run after disposal.
Sourcepub fn on_cleanup(&self, callback: impl FnOnce() + 'static) -> Registration
pub fn on_cleanup(&self, callback: impl FnOnce() + 'static) -> Registration
Run once on disposal (immediately if already disposed).