API reference

aster_blueprint::uitree

Pre-1.0: signatures are not frozen. Generated from rustdoc JSON of the compiled crate; rustdoc JSON format version 60. Only public items are listed.

Text dump + assertions over the rendered UI structure.

A [UiTree] is a plain owned description of what is on screen: ids, names, kinds, logical rects, text labels, theme. Build it by hand while you build the scene ([UiNode]), from keyed scene nodes ([UiTree::from_scene]), or from an acknowledged aster_ui::semantics snapshot ([UiTree::from_semantics]). The scene itself does not store labels, ids or kinds, so the tree is authored metadata, never inferred from pixels.

Structs

structaster_blueprint::uitree::UiNode

pub struct UiNode { /* see fields */ }

Public fields

fieldtype
idStringStable id (what tests address); unique within the tree by convention.
nameStringHuman name (its label).
kindStringFree-form kind: "Button", "Card", "Text", "Chart", ...
rectRect
labelOption<String>Visible text, if the node shows any.
themeOption<String>Theme/variant this node was rendered with, if it differs from the tree's.
hiddenbool
model_keyOption<aster_ui::ModelKey>
flagsVec<String>Interaction state words ("hovered", "pressed", "focused", "disabled", "focusable"); set by [crate::interact::Driver], empty otherwise.
childrenVec<UiNode>
a11yOption<Box<ui::a11y::NodeA11y>>Accessibility facts recorded when the tree was built (see ui::a11y).

Methods

  • fn new(id: impl Into<String>, kind: impl Into<String>, rect: Rect) -> Self
  • fn flag(self, flag: impl Into<String>) -> Self
  • fn has_flag(&self, flag: &str) -> bool
  • fn name(self, name: impl Into<String>) -> Self
  • fn label(self, label: impl Into<String>) -> Self
  • fn theme(self, theme: impl Into<String>) -> Self
  • fn hidden(self, hidden: bool) -> Self
  • fn key(self, key: ModelKey) -> Self
  • fn child(self, child: UiNode) -> Self
  • fn center(&self) -> [f64; 2]

Trait implementations: Clone, Debug, PartialEq, StructuralPartialEq

structaster_blueprint::uitree::UiTree

pub struct UiTree { /* see fields */ }

Public fields

fieldtype
themeOption<String>
viewportOption<Rect>Logical viewport; assert_visible requires intersection with it.
rootsVec<UiNode>

Methods

  • fn new() -> Self
  • fn theme(self, theme: impl Into<String>) -> Self
  • fn viewport(self, width: f64, height: f64) -> Self
  • fn node(self, node: UiNode) -> Self
  • fn from_scene(scene: &Scene, entries: &[(ModelKey, &str, &str, Option<&str>)]) -> Result<Self, String> — Annotate keyed scene nodes: (model key, id, kind, label). Rects are the nodes' scene bounds, untransformed. Nesting follows the scene's parent chain, restricted to annotated nodes. Keys not in the scene are an error.
  • fn from_semantics(snapshot: Snapshot<'_>) -> Self — Reuse an acknowledged aster_ui::semantics snapshot: role -> kind, name -> name and label, hidden state and bounds are carried over.
  • fn iter(&self) -> impl Iterator<Item = &UiNode>
  • fn find_id(&self, id: &str) -> Option<&UiNode>
  • fn find_label(&self, text: &str) -> Option<&UiNode> — First node whose label (or, failing that, name) equals text.
  • fn find_kind<'a>(&self, kind: &'a str) -> impl Iterator<Item = &'a UiNode>
  • fn center_of(&self, id: &str) -> Option<[f64; 2]> — Logical center of a node (for [crate::headless::Headless::hit]).
  • fn dump(&self) -> String — Deterministic text dump, one node per line.
  • fn assert_visible(&self, text: &str) -> &UiNode — Panics (with the full dump) unless a non-hidden, non-empty node labelled text intersects the viewport. Returns it.
  • fn assert_not_visible(&self, text: &str)
  • fn assert_id(&self, id: &str) -> &UiNode
  • fn assert_rect(&self, id: &str, expected: Rect, tol: f64) — Rect of id equals expected within tol logical px on every edge.
  • fn assert_label(&self, id: &str, expected: &str)
  • fn assert_inside(&self, inner: &str, outer: &str, tol: f64) — inner's rect lies inside outer's (within tol).
  • fn assert_flag(&self, id: &str, flag: &str) — id carries interaction flag flag (e.g. "hovered").
  • fn assert_no_flag(&self, id: &str, flag: &str)
  • fn set_flags(&mut self, id: &str, flags: Vec<String>) — Replace the flags of node id (no-op when absent).
  • fn assert_no_overlap(&self, a: &str, b: &str)
  • fn semantics(&self) -> SemanticTree — Map this tree onto aster_ui::semantics: roles, names, values, states (selected, disabled, focused, checked, expanded, invalid, required) and actions. Password-like (.sensitive()) contents are left out.
  • fn audit_overflow(&self) -> Vec<OverflowIssue> — Find the containers whose children do not fit: a width set with .w(..) below a child's min_w (a select face is 180 px unless select_w says less), a text() that never wraps in a narrow column, a row of rigid children wider than its parent. Layout never shrinks a child below its minimum, so this is clamped silently; here it is listed. Scroll containers are skipped (their content is reachable by scrolling) and so are overlays and layers; shapes drawn on purpose past a container (a shadow, a badge) are not children and are not listed. A container is listed when its children stick out by more than 1 px across or 4 px down.
  • fn audit_a11y(&self) -> A11yReport — Check accessibility: unlabelled interactive elements, text below contrast, tab order that jumps backwards on screen, targets under 24x24 px and input fields whose boundary is under 3:1 ([FIELD_KINDS]). Hidden (clipped) and disabled elements are skipped. The text backdrops are measured here, not when the frame was built: a frame that is never audited never pays for them.
  • fn audit_a11y_strict(&self) -> A11yReport — The strict tier, opt-in: [UiTree::audit_a11y] with the non-text contrast check ([UiTree::audit_non_text_contrast]) run on every control instead of the input fields only. A tonal button, a list row, a tab or a card marked by a 6 to 10 % fill alone is reported as LowComponentContrast until it has a boundary: .border(Col::Edge) (the theme's border moved toward the text colour until it is 3:1), or a fill that stands out. Use it when the design aims past WCAG 1.4.11's "the label identifies the component" allowance (ASTER_A11Y_STRICT=1 makes tests/a11y_gate.rs use it).
  • fn audit_non_text_contrast(&self) -> A11yReport — The non-text contrast check (WCAG 1.4.11, opt-in: [UiTree::audit_a11y] does not run it). Every enabled, visible interactive element with a fill or a border must show a boundary of at least [MIN_COMPONENT_CONTRAST]:1 against what is painted behind it: the border or the fill (composited over the backdrop) passing is enough, and a gradient is judged at its worse end. Elements with neither (a text link) are the text check's business, and a backdrop the audit cannot read (a picture, a blend mode) is skipped.
  • fn text_contrasts(&self) -> Vec<(String, TextInfo)> — The measured contrast of every text in the tree, in tree order: the text's ink, the background it was measured against and the ratio. A rich text reports its worst run (the one that misses its threshold by the most; TextInfo::run says which run it is). The backdrops are measured when this is called (the builder only records the paints), so a frame that is never asked pays nothing.

Trait implementations: Clone, Debug, Default, PartialEq, StructuralPartialEq

Type aliases

typeaster_blueprint::uitree::Rect

pub type Rect = [f64; 4];

Logical-pixel rectangle [x, y, width, height].