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: WidgetTypeThe type of widget
label: Option<String>Human-readable label
id: Option<String>Programmatic identifier
focused: boolWhether this widget currently has focus
disabled: boolWhether this widget is disabled
selected: boolWhether 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
impl Annotation
Sourcepub fn new(widget_type: WidgetType) -> Self
pub fn new(widget_type: WidgetType) -> Self
Creates a new annotation with the given widget type.
Creates a button annotation.
Creates a menu item annotation.
Sourcepub fn custom(type_name: impl Into<String>, id: impl Into<String>) -> Self
pub fn custom(type_name: impl Into<String>, id: impl Into<String>) -> Self
Creates a custom widget annotation.
Sourcepub fn with_label(self, label: impl Into<String>) -> Self
pub fn with_label(self, label: impl Into<String>) -> Self
Sets the label.
Sourcepub fn with_focus(self, focused: bool) -> Self
pub fn with_focus(self, focused: bool) -> Self
Sets the focused state.
Sourcepub fn with_disabled(self, disabled: bool) -> Self
pub fn with_disabled(self, disabled: bool) -> Self
Sets the disabled state.
Sourcepub fn with_selected(self, selected: bool) -> Self
pub fn with_selected(self, selected: bool) -> Self
Sets the selected state.
Sourcepub fn with_expanded(self, expanded: bool) -> Self
pub fn with_expanded(self, expanded: bool) -> Self
Sets the expanded state.
Sourcepub fn with_value(self, value: impl Into<String>) -> Self
pub fn with_value(self, value: impl Into<String>) -> Self
Sets the current value.
Sourcepub fn with_meta(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_meta(self, key: impl Into<String>, value: impl Into<String>) -> Self
Adds metadata.
Sourcepub fn is_type(&self, widget_type: &WidgetType) -> bool
pub fn is_type(&self, widget_type: &WidgetType) -> bool
Returns true if this annotation has the given widget type.
Sourcepub fn is_interactive(&self) -> bool
pub fn is_interactive(&self) -> bool
Returns true if this is an interactive widget.
Sourcepub fn description(&self) -> String
pub fn description(&self) -> String
Returns a description suitable for display.
Trait Implementations§
Source§impl Clone for Annotation
impl Clone for Annotation
Source§fn clone(&self) -> Annotation
fn clone(&self) -> Annotation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Annotation
impl Debug for Annotation
Source§impl Default for Annotation
impl Default for Annotation
Source§impl<'de> Deserialize<'de> for Annotation
impl<'de> Deserialize<'de> for Annotation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for Annotation
impl PartialEq for Annotation
Source§impl Serialize for Annotation
impl Serialize for Annotation
impl Eq for Annotation
impl StructuralPartialEq for Annotation
Auto Trait Implementations§
impl Freeze for Annotation
impl RefUnwindSafe for Annotation
impl Send for Annotation
impl Sync for Annotation
impl Unpin for Annotation
impl UnwindSafe for Annotation
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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