pub struct ArcNode(/* private fields */);Expand description
A reference counted UiNode.
Nodes can only be used in one place at a time, this struct allows the
creation of slots that are UiNode implementers that can exclusive take the
referenced node as its child.
When a slot takes the node it is deinited in the previous place and reinited in the slot place.
Slots hold a strong reference to the node when they have it as their child and a weak reference when they don’t.
Implementations§
Source§impl ArcNode
impl ArcNode
Sourcepub fn new(node: impl IntoUiNode) -> Self
pub fn new(node: impl IntoUiNode) -> Self
New node.
Sourcepub fn new_cyclic(node: impl FnOnce(WeakNode) -> UiNode) -> Self
pub fn new_cyclic(node: impl FnOnce(WeakNode) -> UiNode) -> Self
New node that contains a weak reference to itself.
Note that the weak reference cannot be upgraded during the call to node.
Sourcepub fn set(&self, new_node: impl IntoUiNode)
pub fn set(&self, new_node: impl IntoUiNode)
Replace the current node with the new_node in the current slot.
The previous node is deinited and the new_node is inited.
Sourcepub fn take_when(&self, var: impl IntoVar<bool>) -> UiNode
pub fn take_when(&self, var: impl IntoVar<bool>) -> UiNode
Create a slot node that takes ownership of this node when var updates to true.
The slot node also takes ownership on init if the var is already true.
Sourcepub fn take_on<A, F>(
&self,
event: Event<A>,
filter: F,
take_on_init: bool,
) -> UiNode
pub fn take_on<A, F>( &self, event: Event<A>, filter: F, take_on_init: bool, ) -> UiNode
Create a slot node that takes ownership of this node when event updates and filter returns true.
The slot node also takes ownership on init if take_on_init is true.
Sourcepub fn take_on_init(&self) -> UiNode
pub fn take_on_init(&self) -> UiNode
Create a slot node that takes ownership of this node as soon as the node is inited.
This is equivalent to self.take_when(true).
Sourcepub fn try_node<R>(&self, visitor: impl FnOnce(&mut UiNode) -> R) -> Option<R>
pub fn try_node<R>(&self, visitor: impl FnOnce(&mut UiNode) -> R) -> Option<R>
Call visitor on a exclusive lock of the node.
Note that the node is not visited in their current slot context, only use this to inspect state.
Returns None if the node is locked, this will happen if calling from inside the node or an ancestor.
Sourcepub fn try_context<R>(
&self,
update_mode: WidgetUpdateMode,
visitor: impl FnOnce() -> R,
) -> Option<R>
pub fn try_context<R>( &self, update_mode: WidgetUpdateMode, visitor: impl FnOnce() -> R, ) -> Option<R>
Calls visitor in the widget context of the node, if it is an widget.
Note that only the widget context is loaded in visitor, not the full slot context.
Returns None if the node is locked or is not an widget. The node will be locked if calling from inside the node or an ancestor.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ArcNode
impl !RefUnwindSafe for ArcNode
impl Send for ArcNode
impl Sync for ArcNode
impl Unpin for ArcNode
impl !UnwindSafe for ArcNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more