Skip to main content

Tree

Struct Tree 

Source
pub struct Tree {
    pub app_name: String,
    pub pid: Option<u32>,
    pub screen_size: (u32, u32),
    /* private fields */
}
Expand description

A snapshot of an application’s accessibility tree.

The tree is a flattened snapshot — nodes are stored in DFS order and reference each other by internal indices.

This type is internal to provider implementations. End users should use Node (returned by xa11y::app(), etc.) which wraps a Tree with navigation methods.

Fields§

§app_name: String

Application name

§pid: Option<u32>

Process ID. None for multi-app queries.

§screen_size: (u32, u32)

Screen dimensions at capture time (width, height)

Implementations§

Source§

impl Tree

Source

pub fn new( app_name: String, pid: Option<u32>, screen_size: (u32, u32), nodes: Vec<NodeData>, ) -> Self

Create a new Tree from a list of nodes.

Source

pub fn get_data(&self, index: u32) -> Option<&NodeData>

Get a node’s data by its internal index.

Source

pub fn root_data(&self) -> &NodeData

Get the root node data.

Source

pub fn parent_data(&self, node: &NodeData) -> Option<&NodeData>

Get the parent of a node.

Source

pub fn children_data(&self, node: &NodeData) -> Vec<&NodeData>

Get direct children of a node.

Source

pub fn subtree_indices(&self, index: u32) -> Vec<u32>

Get indices of the subtree rooted at a node (including the node itself).

Source

pub fn iter(&self) -> impl Iterator<Item = &NodeData>

Iterate all node data.

Source

pub fn query_indices(&self, selector_str: &str) -> Result<Vec<u32>>

Query node indices matching a CSS-like selector string.

Source

pub fn query(&self, selector_str: &str) -> Result<Vec<&NodeData>>

Query nodes matching a CSS-like selector string (returns NodeData refs).

Source

pub fn len(&self) -> usize

Get the number of nodes in the tree.

Source

pub fn is_empty(&self) -> bool

Check if the tree is empty.

Trait Implementations§

Source§

impl Clone for Tree

Source§

fn clone(&self) -> Tree

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Tree

Source§

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

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

impl<'de> Deserialize<'de> for Tree

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Tree

Source§

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

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

impl Serialize for Tree

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl Freeze for Tree

§

impl RefUnwindSafe for Tree

§

impl Send for Tree

§

impl Sync for Tree

§

impl Unpin for Tree

§

impl UnsafeUnpin for Tree

§

impl UnwindSafe for Tree

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,