pub struct MessageProcessor {
pub model: SurfaceGroupModel,
/* private fields */
}Expand description
Parses A2UI JSON messages and applies them to the state models.
Fields§
§model: SurfaceGroupModelThe state model (all active surfaces).
Implementations§
Source§impl MessageProcessor
impl MessageProcessor
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Reset all processed state (surfaces and outgoing messages) while keeping the registered catalogs intact.
Use this to replay a sample from scratch instead of constructing a new
processor with MessageProcessor::new(vec![]), which would silently
drop the catalogs and cause every component type to be flagged as
“unknown”.
Sourcepub fn parse_message(json: &str) -> Result<A2uiMessage>
pub fn parse_message(json: &str) -> Result<A2uiMessage>
Parse a raw JSON string into an A2uiMessage.
Sourcepub fn parse_jsonl(jsonl: &str) -> Vec<Result<A2uiMessage>> ⓘ
pub fn parse_jsonl(jsonl: &str) -> Vec<Result<A2uiMessage>> ⓘ
Parse a JSONL stream (newline-delimited JSON objects).
Sourcepub fn process_message(&mut self, msg: A2uiMessage) -> Result<()>
pub fn process_message(&mut self, msg: A2uiMessage) -> Result<()>
Process a single parsed message.
Sourcepub fn process_messages(
&mut self,
messages: Vec<A2uiMessage>,
) -> Vec<Result<()>> ⓘ
pub fn process_messages( &mut self, messages: Vec<A2uiMessage>, ) -> Vec<Result<()>> ⓘ
Process multiple messages sequentially.
Sourcepub fn drain_outgoing(&mut self) -> Vec<ClientMessage>
pub fn drain_outgoing(&mut self) -> Vec<ClientMessage>
Drain outgoing client-to-server messages produced during processing.
Call this after process_message / process_messages to retrieve
any functionResponse, error, or other client messages that should
be sent back to the server.
Sourcepub fn catalog_type_exists(&self, component_type: &str) -> bool
pub fn catalog_type_exists(&self, component_type: &str) -> bool
Check if a component type exists in any registered catalog.
Sourcepub fn registered_catalog_ids(&self) -> Vec<String>
pub fn registered_catalog_ids(&self) -> Vec<String>
Return the IDs of all registered catalogs (native + inline).
Sourcepub fn register_inline_catalog(&mut self, json: Value) -> Result<()>
pub fn register_inline_catalog(&mut self, json: Value) -> Result<()>
Register an inline catalog from a raw JSON value.
The catalog is parsed via [capabilities::parse_inline_catalog]. Each
declared function becomes a [SchemaOnlyFunction] in a fresh
Catalog (so handle_call_function can discover and reject
execution attempts). Declared components have no native renderer and
are not added to catalog.components — at render time they fall
back to the generic renderer.
Sourcepub fn register_action(
&mut self,
surface_id: &str,
action_id: &str,
response_path: Option<String>,
) -> Result<()>
pub fn register_action( &mut self, surface_id: &str, action_id: &str, response_path: Option<String>, ) -> Result<()>
Register a pending action that expects a server response.
Call this when the caller sends an action message with
wantResponse: true. The response_path (if any) tells the
processor where to store the server’s response value in the data model.
Sourcepub fn load_sample(json: &str) -> Result<(String, String, Vec<A2uiMessage>)>
pub fn load_sample(json: &str) -> Result<(String, String, Vec<A2uiMessage>)>
Load a sample file (wrapping messages in {name, description, messages}).