#[non_exhaustive]pub struct ElementData {Show 14 fields
pub role: Role,
pub name: Option<String>,
pub value: Option<String>,
pub description: Option<String>,
pub bounds: Option<Rect>,
pub actions: Vec<String>,
pub states: StateSet,
pub numeric_value: Option<f64>,
pub min_value: Option<f64>,
pub max_value: Option<f64>,
pub stable_id: Option<String>,
pub pid: Option<u32>,
pub raw: RawPlatformData,
pub handle: u64,
}Expand description
The raw data for a single element in an accessibility tree.
This is the underlying data struct. Most consumers should use
Element, which wraps ElementData with a provider reference for
lazy navigation. ElementData is used directly by provider
implementors.
#[non_exhaustive]: this is the type that grows every time the
normalized element model learns a new property, so adding a field must
not break the consumers that only ever read one. Providers, which
write one, get the opposite guarantee from [ElementParts].
Build a partial element (an event target, a test fixture) with
ElementData::for_role and assign what you have:
let mut data = ElementData::for_role(Role::Button);
data.name = Some("Submit".to_string());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.role: RoleElement role
name: Option<String>Human-readable name (title, label).
Stripped of Unicode bidi format controls (LRM, RLM, embeddings,
overrides, isolates) so equality assertions match the logical text.
The unstripped platform string is preserved in Self::raw under the
platform-native key (e.g. AXTitle on macOS, atspi_name on Linux,
uia_name on Windows). See crate::text::strip_bidi.
value: Option<String>Current value (text content, slider position, etc.).
Stripped of Unicode bidi format controls. The unstripped platform
string is preserved in Self::raw (AXValue on macOS, atspi_value
on Linux, uia_value on Windows). See crate::text::strip_bidi.
description: Option<String>Supplementary description (tooltip, help text).
Stripped of Unicode bidi format controls. The unstripped platform
string is preserved in Self::raw (AXDescription/AXHelp on
macOS, atspi_description on Linux, uia_help_text on Windows).
See crate::text::strip_bidi.
bounds: Option<Rect>Bounding rectangle in desktop coordinates: physical pixels on
Windows and logical points on macOS and Linux. The origin is the
top-left of the primary display. This is the space accepted by
crate::ScreenshotProvider::capture_region and by the input layer’s
crate::input::Point, so bounds can be fed directly to
screenshot_element / click without conversion.
To map into an actual captured image, use
crate::Screenshot::desktop_rect_to_image. One scalar scale is
insufficient when bounds cross displays or the image was resized.
actions: Vec<String>Available actions reported by the platform.
Names are snake_case strings — well-known actions use their standard
names ("press", "toggle", "expand", etc.) and platform-specific
actions use their converted names (e.g. macOS AXCustomThing →
"custom_thing").
states: StateSetCurrent state flags
numeric_value: Option<f64>Numeric value for range controls (sliders, progress bars, spinners).
min_value: Option<f64>Minimum value for range controls.
max_value: Option<f64>Maximum value for range controls.
stable_id: Option<String>Platform-assigned stable identifier for cross-snapshot correlation.
- macOS:
AXIdentifier - Windows: native window handle (
hwnd:0x…) for top-level windows,AutomationIdfor the elements that have one — UIA excludes top-level windows from the AutomationId contract, and the handle is session-scoped (like the Linux object path; HWNDs are reused after a window closes) - Linux: D-Bus
object_path
Not all elements have one.
pid: Option<u32>Process ID of the application that owns this element.
raw: RawPlatformDataPlatform-specific raw data
handle: u64Opaque handle for the provider to look up the platform object. Not serialized — only valid within the provider that created it.
Implementations§
Source§impl ElementData
impl ElementData
Sourcepub fn for_role(role: Role) -> Self
pub fn for_role(role: Role) -> Self
An element with the given role and every other field empty.
states starts at StateSet::default (enabled and visible, nothing
else), and handle at 0 — providers assign their own.
This is the partial construction path. A provider translating a real
platform node should use [ElementParts] instead, so that a new field
fails its build rather than arriving as a default.
Named for_role rather than new because ElementData is flattened
onto Element for the bindings-parity check, where a member called
new would collide with the existing Element::new.
Trait Implementations§
Source§impl Clone for ElementData
impl Clone for ElementData
Source§impl Debug for ElementData
impl Debug for ElementData
Source§impl Default for ElementData
impl Default for ElementData
Source§fn default() -> Self
fn default() -> Self
A Role::Unknown element with no properties.