Skip to main content

Catalog

Struct Catalog 

Source
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: String

Opaque 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

Source

pub fn empty(catalog_id: impl Into<String>) -> Self

An empty catalog with the given id.

Source

pub fn component(&self, name: &str) -> Option<&ComponentDef>

Looks up a component type.

Source

pub fn has_component(&self, name: &str) -> bool

Whether this catalog defines the given component type.

Source

pub fn components_in_order(&self) -> impl Iterator<Item = &ComponentDef>

Component types in declaration order.

Source

pub fn insert_component(&mut self, def: ComponentDef)

Adds or replaces a component type.

Source

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.

Source

pub fn basic() -> Self

The standard 18-component basic catalog.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for Catalog

Source§

fn clone(&self) -> Catalog

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Catalog

Source§

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

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

impl Eq for Catalog

Source§

impl PartialEq for Catalog

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · 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 StructuralPartialEq for Catalog

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more