i_slint_backend_testing

Struct ElementQuery

Source
pub struct ElementQuery { /* private fields */ }
Expand description

Use ElementQuery to form a query into the tree of UI elements and then locate one or multiple matching elements.

ElementQuery uses the builder pattern to concatenate criteria, such as searching for descendants, or matching elements only with a certain id.

Construct an instance of this by calling ElementQuery::from_root or ElementHandle::query_descendants. Apply additional criterial on the returned ElementQuery and fetch results by either calling Self::find_first() to collect just the first match or Self::find_all() to collect all matches for the query.

Implementations§

Source§

impl ElementQuery

Source

pub fn from_root(component: &impl ElementRoot) -> Self

Creates a new element query starting at the root of the tree and matching all descendants.

Source

pub fn match_descendants(self) -> Self

Applies any subsequent matches to all descendants of the results of the query up to this point.

Source

pub fn match_id(self, id: impl Into<String>) -> Self

Include only elements in the results where ElementHandle::id() is equal to the provided id.

Source

pub fn match_type_name(self, type_name: impl Into<String>) -> Self

Include only elements in the results where ElementHandle::type_name() is equal to the provided type_name.

Source

pub fn match_inherits(self, type_name: impl Into<String>) -> Self

Include only elements in the results where ElementHandle::type_name() or ElementHandle::bases() is contains to the provided type_name.

Source

pub fn match_accessible_role(self, role: AccessibleRole) -> Self

Include only elements in the results where ElementHandle::accessible_role() is equal to the provided role.

Source

pub fn match_predicate( self, predicate: impl Fn(&ElementHandle) -> bool + 'static, ) -> Self

Source

pub fn find_first(&self) -> Option<ElementHandle>

Runs the query and returns the first result; returns None if no element matches the selected criteria.

Source

pub fn find_all(&self) -> Vec<ElementHandle>

Runs the query and returns a vector of all matching elements.

Auto Trait Implementations§

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> 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, 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.