Skip to main content

Annotation

Struct Annotation 

Source
pub struct Annotation {
    pub widget_type: WidgetType,
    pub label: Option<String>,
    pub id: Option<String>,
    pub focused: bool,
    pub disabled: bool,
    pub selected: bool,
    pub expanded: Option<bool>,
    pub value: Option<String>,
    pub metadata: HashMap<String, String>,
}
Expand description

Metadata annotation for a widget.

Annotations provide semantic information about widgets that can be used for testing, accessibility, and UI queries.

Fields§

§widget_type: WidgetType

The type of widget

§label: Option<String>

Human-readable label

§id: Option<String>

Programmatic identifier

§focused: bool

Whether this widget currently has focus

§disabled: bool

Whether this widget is disabled

§selected: bool

Whether this widget is selected (for selectable items)

§expanded: Option<bool>

Whether this widget is expanded (for collapsible items)

§value: Option<String>

Current value (for inputs, etc.)

§metadata: HashMap<String, String>

Additional metadata

Implementations§

Source§

impl Annotation

Source

pub fn new(widget_type: WidgetType) -> Self

Creates a new annotation with the given widget type.

Source

pub fn container(id: impl Into<String>) -> Self

Creates a container annotation.

Source

pub fn dialog(title: impl Into<String>) -> Self

Creates a dialog annotation.

Source

pub fn button(id: impl Into<String>) -> Self

Creates a button annotation.

Source

pub fn input(id: impl Into<String>) -> Self

Creates an input field annotation.

Source

pub fn text_area(id: impl Into<String>) -> Self

Creates a text area annotation.

Source

pub fn checkbox(id: impl Into<String>) -> Self

Creates a checkbox annotation.

Source

pub fn list(id: impl Into<String>) -> Self

Creates a list annotation.

Source

pub fn table(id: impl Into<String>) -> Self

Creates a table annotation.

Source

pub fn tab(id: impl Into<String>) -> Self

Creates a tab annotation.

Source

pub fn menu_item(id: impl Into<String>) -> Self

Creates a menu item annotation.

Source

pub fn label(text: impl Into<String>) -> Self

Creates a label annotation.

Source

pub fn header(text: impl Into<String>) -> Self

Creates a header annotation.

Source

pub fn custom(type_name: impl Into<String>, id: impl Into<String>) -> Self

Creates a custom widget annotation.

Source

pub fn with_label(self, label: impl Into<String>) -> Self

Sets the label.

Source

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

Sets the id.

Source

pub fn with_focus(self, focused: bool) -> Self

Sets the focused state.

Source

pub fn with_disabled(self, disabled: bool) -> Self

Sets the disabled state.

Source

pub fn with_selected(self, selected: bool) -> Self

Sets the selected state.

Source

pub fn with_expanded(self, expanded: bool) -> Self

Sets the expanded state.

Source

pub fn with_value(self, value: impl Into<String>) -> Self

Sets the current value.

Source

pub fn with_meta(self, key: impl Into<String>, value: impl Into<String>) -> Self

Adds metadata.

Source

pub fn has_id(&self, id: &str) -> bool

Returns true if this annotation matches the given id.

Source

pub fn is_type(&self, widget_type: &WidgetType) -> bool

Returns true if this annotation has the given widget type.

Source

pub fn is_interactive(&self) -> bool

Returns true if this is an interactive widget.

Source

pub fn description(&self) -> String

Returns a description suitable for display.

Trait Implementations§

Source§

impl Clone for Annotation

Source§

fn clone(&self) -> Annotation

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 Annotation

Source§

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

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

impl Default for Annotation

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Annotation

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 PartialEq for Annotation

Source§

fn eq(&self, other: &Annotation) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Annotation

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
Source§

impl Eq for Annotation

Source§

impl StructuralPartialEq for Annotation

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> 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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.
Source§

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