Trait kas::LayoutExt

source ·
pub trait LayoutExt: Layout {
    // Provided methods
    fn id(&self) -> Id { ... }
    fn eq_id<T>(&self, rhs: T) -> bool
       where Id: PartialEq<T> { ... }
    fn identify(&self) -> IdentifyWidget<'_> { ... }
    fn is_ancestor_of(&self, id: &Id) -> bool { ... }
    fn is_strict_ancestor_of(&self, id: &Id) -> bool { ... }
    fn for_children(&self, f: impl FnMut(&dyn Layout)) { ... }
    fn for_children_try<E>(
        &self,
        f: impl FnMut(&dyn Layout) -> Result<(), E>
    ) -> Result<(), E> { ... }
    fn find_widget(&self, id: &Id) -> Option<&dyn Layout> { ... }
}
Expand description

Extension trait over widgets

Provided Methods§

source

fn id(&self) -> Id

Get the widget’s identifier

Note that the default-constructed Id is invalid: any operations on this value will cause a panic. Valid identifiers are assigned during configure.

source

fn eq_id<T>(&self, rhs: T) -> bool
where Id: PartialEq<T>,

Test widget identifier for equality

This method may be used to test against Id, Option<Id> and Option<&Id>.

source

fn identify(&self) -> IdentifyWidget<'_>

Display as “StructName#Id”

source

fn is_ancestor_of(&self, id: &Id) -> bool

Check whether id is self or a descendant

This function assumes that id is a valid widget.

source

fn is_strict_ancestor_of(&self, id: &Id) -> bool

Check whether id is not self and is a descendant

This function assumes that id is a valid widget.

source

fn for_children(&self, f: impl FnMut(&dyn Layout))

Run a closure on all children

source

fn for_children_try<E>( &self, f: impl FnMut(&dyn Layout) -> Result<(), E> ) -> Result<(), E>

Run a fallible closure on all children

Returns early in case of error.

source

fn find_widget(&self, id: &Id) -> Option<&dyn Layout>

Find the descendant with this id, if any

Since id represents a path, this operation is normally O(d) where d is the depth of the path (depending on widget implementations).

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<W> LayoutExt for W
where W: Layout + ?Sized,