Skip to main content

AsyncStreamingHandler

Trait AsyncStreamingHandler 

Source
pub trait AsyncStreamingHandler: Send + Sync {
Show 14 methods // Required methods fn add_status_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn add_artifact_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_subscription<'life0, 'life1, 'async_trait>( &'life0 self, subscription_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn remove_task_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn get_subscriber_count<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn broadcast_status_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskStatusUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn broadcast_artifact_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskArtifactUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn status_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskStatusUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn artifact_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskArtifactUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn combined_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, from_event_id: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<SeqEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn has_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn validate_streaming_params<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn start_task_streaming<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, from_event_id: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<SeqEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn stop_task_streaming<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... }
}
Expand description

An async trait for managing streaming connections and real-time updates

Required Methods§

Source

fn add_status_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add a status update subscriber for a task

Source

fn add_artifact_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Add an artifact update subscriber for a task

Source

fn remove_subscription<'life0, 'life1, 'async_trait>( &'life0 self, subscription_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove a specific subscription

Source

fn remove_task_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove all subscribers for a task

Source

fn get_subscriber_count<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the number of active subscribers for a task

Source

fn broadcast_status_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskStatusUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcast a status update to all subscribers of a task

Source

fn broadcast_artifact_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskArtifactUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Broadcast an artifact update to all subscribers of a task

Source

fn status_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskStatusUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a stream of status updates for a task

Source

fn artifact_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskArtifactUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a stream of artifact updates for a task

Source

fn combined_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, from_event_id: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<SeqEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create a combined stream of all updates for a task.

Each yielded SeqEvent carries a per-task monotonic id so a client can resume after a disconnect. When from_event_id is Some(n), the handler first replays any buffered events with id > n (best-effort, bounded by the handler’s replay buffer) before streaming live updates.

Provided Methods§

Source

fn has_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if a task has any active subscribers

Source

fn validate_streaming_params<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Validate streaming parameters

Source

fn start_task_streaming<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, from_event_id: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<SeqEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Start streaming for a task with automatic cleanup.

from_event_id is forwarded to combined_update_stream for Last-Event-ID resumption.

Source

fn stop_task_streaming<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Stop all streaming for a task

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl AsyncStreamingHandler for Arc<dyn AsyncStreamingHandler>

Forwarding impl so a type-erased Arc<dyn AsyncStreamingHandler> can itself be passed wherever an impl AsyncStreamingHandler is expected (e.g. TaskService::with_streaming_handler). This lets a single shared streaming backend be injected into both a message handler and a transport adapter without naming its concrete type. Only the required methods are forwarded; the trait’s default methods ride along on top of them.

Source§

fn add_status_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn add_artifact_subscriber<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>, ) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn remove_subscription<'life0, 'life1, 'async_trait>( &'life0 self, subscription_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn remove_task_subscribers<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn get_subscriber_count<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<usize, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn broadcast_status_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskStatusUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn broadcast_artifact_update<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, update: TaskArtifactUpdateEvent, ) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn status_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskStatusUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn artifact_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskArtifactUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn combined_update_stream<'life0, 'life1, 'async_trait>( &'life0 self, task_id: &'life1 str, from_event_id: Option<u64>, ) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<SeqEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§