pub trait TaskStatusBroadcast:
HasTaskLifecycle
+ HasStreaming
+ HasPushNotifier
+ Send
+ Sync {
// Provided methods
fn update_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
state: TaskState,
message: Option<Message>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn cancel_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn broadcast_artifact<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
event: TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Derived capability: mutate task status through the lifecycle port, then broadcast the resulting status to streaming subscribers.
Blanket-implemented for every Send + Sync host that exposes both
ingredients, so it never needs an explicit impl. A host that exposes only
one ingredient does not get this method — that omission is a compile
error at the call site, not a runtime surprise (see the compile_fail doc
test on update_and_broadcast).
Provided Methods§
Sourcefn update_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
state: TaskState,
message: Option<Message>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
state: TaskState,
message: Option<Message>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Update a task’s status, then broadcast the new status to subscribers.
The broadcast is best-effort relative to the store: the status is persisted first (via the lifecycle port) and only then announced, so a subscriber never sees a state the store hasn’t committed.
A host that exposes only one of the two ingredients does not get this method — the missing supertrait makes the blanket impl inapplicable, so the call fails to compile:
use std::sync::Arc;
use a2a_rs::AsyncTaskLifecycle;
use a2a_rs::adapter::storage::InMemoryTaskStorage;
use a2a_rs::application::{HasTaskLifecycle, TaskStatusBroadcast};
use a2a_rs::domain::{TaskId, TaskState};
// Exposes the lifecycle ingredient, but NOT `HasStreaming`.
struct HalfRig {
store: Arc<InMemoryTaskStorage>,
}
impl HasTaskLifecycle for HalfRig {
fn lifecycle(&self) -> &dyn AsyncTaskLifecycle {
self.store.as_ref()
}
}
async fn use_it(rig: HalfRig, id: TaskId) {
// `update_and_broadcast` does not exist on a one-ingredient host:
rig.update_and_broadcast(&id, TaskState::Completed, None).await.unwrap();
}Sourcefn cancel_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_and_broadcast<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel a task through the lifecycle port, then broadcast the resulting (terminal) status to subscribers.
The counterpart to update_and_broadcast
for cancellation: cancel carries its own state transition and history
message, so it cannot be expressed as an update_status call, but the
“commit then announce” ordering is identical.
Sourcefn broadcast_artifact<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
event: TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn broadcast_artifact<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 TaskId,
event: 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: fan it out to streaming subscribers, then deliver it to the task’s push endpoint (best-effort).
The artifact counterpart to the status path. Hosts that produce artifacts
route through here so streaming and push stay consistent — exactly as the
status mutators do via broadcast_current_status.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl<T: HasTaskLifecycle + HasStreaming + HasPushNotifier + Send + Sync + ?Sized> TaskStatusBroadcast for T
The single blanket impl — the linchpin of the pattern. ?Sized lets the
mixin attach to a dyn-typed host as well as a concrete one.