Skip to main content

a2ui_base/catalog/
component_api.rs

1//! Framework-agnostic component API definition.
2
3/// The framework-agnostic definition of a component: its name and schema.
4pub trait ComponentApi: Send + Sync + 'static {
5    /// The component name as it appears in A2UI JSON (e.g. "Button", "Text").
6    fn name(&self) -> &'static str;
7
8    /// Validate component properties against catalog constraints.
9    ///
10    /// Returns `Ok(())` if valid, or a `Vec<String>` of validation error messages.
11    fn validate_properties(&self, _properties: &serde_json::Map<String, serde_json::Value>) -> std::result::Result<(), Vec<String>> {
12        Ok(()) // default: no validation
13    }
14}
15
16// NOTE: Individual TUI components implement ComponentApi manually in the
17// tui catalog builders (minimal.rs, basic.rs) via wrapper types or directly.
18// A blanket impl from TuiComponent is not possible here because core must
19// not depend on the tui layer.