pub struct Catalog {
pub catalog_id: String,
pub title: Option<String>,
pub description: Option<String>,
pub instructions: Option<String>,
pub components: BTreeMap<String, ComponentDef>,
pub functions: BTreeMap<String, FunctionDef>,
/* private fields */
}Expand description
A set of component and function definitions, identified by catalogId.
Fields§
§catalog_id: StringOpaque identifier agent and renderer negotiate on.
title: Option<String>Human-readable title.
description: Option<String>Human-readable description.
instructions: Option<String>Markdown design guidance specific to this catalog, for prompts.
components: BTreeMap<String, ComponentDef>Component types, keyed by name.
functions: BTreeMap<String, FunctionDef>Functions, keyed by name.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub fn component(&self, name: &str) -> Option<&ComponentDef>
pub fn component(&self, name: &str) -> Option<&ComponentDef>
Looks up a component type.
Sourcepub fn has_component(&self, name: &str) -> bool
pub fn has_component(&self, name: &str) -> bool
Whether this catalog defines the given component type.
Sourcepub fn components_in_order(&self) -> impl Iterator<Item = &ComponentDef>
pub fn components_in_order(&self) -> impl Iterator<Item = &ComponentDef>
Component types in declaration order.
Sourcepub fn insert_component(&mut self, def: ComponentDef)
pub fn insert_component(&mut self, def: ComponentDef)
Adds or replaces a component type.
Sourcepub fn references(&self, component: &Component) -> Vec<ComponentRef>
pub fn references(&self, component: &Component) -> Vec<ComponentRef>
Every component id referenced by component, using this catalog’s
structural property definitions.
Returns an empty list for an unknown component type: without a definition there is no way to tell a child reference from a label.
Sourcepub fn from_schema(schema: &Value) -> Result<Self>
pub fn from_schema(schema: &Value) -> Result<Self>
Parses an A2UI catalog JSON Schema document.
Understands the shape the specification uses: a top-level components
map whose values are JSON Schemas, each typically an allOf of shared
fragments plus a final object holding properties and required. The
allOf members are merged; $refs to ComponentId and ChildList are
what mark a property structural.
§Errors
Returns Error::Catalog if the document is not an object or has no
catalogId.
Sourcepub fn composition_violations(
&self,
components: &[Component],
) -> Vec<CompositionViolation>
pub fn composition_violations( &self, components: &[Component], ) -> Vec<CompositionViolation>
Checks allowedParents / allowedChildren across a component tree.
Kept separate from crate::validate on purpose: the specification
assigns composition failures their own renderer-side error codes
(UNALLOWED_PARENT, UNALLOWED_CHILD), distinct from the structural
validation codes. Components with no declared constraints never produce
violations, which is every component of the basic catalog.
The root component’s parent is the implicit
Surface container.
Sourcepub fn render_summary(&self) -> String
pub fn render_summary(&self) -> String
Renders the catalog as a compact summary for a generating model.
One line per component with its required and optional properties, plus
the function list. This is the cheap alternative to pasting the whole
JSON Schema; when a model needs the exact document instead, use
SchemaBundle::render_llm_instructions.
Trait Implementations§
impl Eq for Catalog
impl StructuralPartialEq for Catalog
Auto Trait Implementations§
impl Freeze for Catalog
impl RefUnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl UnsafeUnpin for Catalog
impl UnwindSafe for Catalog
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.