Tree

Struct Tree 

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. Navigation is done through Tree methods that accept &Node references.

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§

§

impl Tree

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

Create a new Tree from a list of nodes.

pub fn get(&self, index: u32) -> Option<&Node>

Get a node by its internal index. Primarily for FFI consumers.

pub fn root(&self) -> &Node

Get the root node.

pub fn parent(&self, node: &Node) -> Option<&Node>

Get the parent of a node.

pub fn children(&self, node: &Node) -> Vec<&Node>

Get direct children of a node.

pub fn subtree(&self, node: &Node) -> Vec<&Node>

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

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

Iterate all nodes.

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

Query nodes matching a CSS-like selector string.

pub fn dump(&self) -> String

Render the tree as an indented text representation for debugging.

pub fn len(&self) -> usize

Get the number of nodes in the tree.

pub fn is_empty(&self) -> bool

Check if the tree is empty.

Trait Implementations§

§

impl Clone for Tree

§

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
§

impl Debug for Tree

§

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

Formats the value using the given formatter. Read more
§

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

§

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

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

impl Serialize for Tree

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::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 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

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