pub struct InMemoryTaskStorage { /* private fields */ }
Expand description
Simple in-memory task storage for testing and example purposes
Implementations§
Source§impl InMemoryTaskStorage
impl InMemoryTaskStorage
Sourcepub fn with_push_sender(
push_sender: impl PushNotificationSender + 'static,
) -> Self
pub fn with_push_sender( push_sender: impl PushNotificationSender + 'static, ) -> Self
Create a new task storage with a custom push notification sender
Sourcepub async fn add_status_subscriber_legacy(
&self,
task_id: &str,
subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>,
) -> Result<(), A2AError>
pub async fn add_status_subscriber_legacy( &self, task_id: &str, subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>, ) -> Result<(), A2AError>
Add a status update subscriber for streaming (convenience method)
Sourcepub async fn add_artifact_subscriber_legacy(
&self,
task_id: &str,
subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>,
) -> Result<(), A2AError>
pub async fn add_artifact_subscriber_legacy( &self, task_id: &str, subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>, ) -> Result<(), A2AError>
Add an artifact update subscriber for streaming (convenience method)
Trait Implementations§
Source§impl AsyncNotificationManager for InMemoryTaskStorage
impl AsyncNotificationManager for InMemoryTaskStorage
Source§fn set_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn set_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Set up push notifications for a task
Source§fn get_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get the push notification configuration for a task
Source§fn remove_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn remove_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Remove push notification configuration for a task
Source§fn has_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn has_task_notification<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Check if push notifications are configured for a task
Source§fn validate_notification_config<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a PushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn validate_notification_config<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a PushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Validate push notification configuration
Source§fn send_test_notification<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a PushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn send_test_notification<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a PushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Send a test notification to verify configuration
Source§fn set_task_notification_validated<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn set_task_notification_validated<'a, 'life0, 'async_trait>(
&'life0 self,
config: &'a TaskPushNotificationConfig,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Set task notification with validation
Source§fn get_task_notification_validated<'a, 'life0, 'async_trait>(
&'life0 self,
params: &'a TaskIdParams,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_task_notification_validated<'a, 'life0, 'async_trait>(
&'life0 self,
params: &'a TaskIdParams,
) -> Pin<Box<dyn Future<Output = Result<TaskPushNotificationConfig, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get task notification with validation
Source§fn notify_task_status_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
_status_update: &'a TaskStatusUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn notify_task_status_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
_status_update: &'a TaskStatusUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Send notification for task status update
Source§fn notify_task_artifact_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
_artifact_update: &'a TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn notify_task_artifact_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
_artifact_update: &'a TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Send notification for task artifact update
Source§impl AsyncStreamingHandler for InMemoryTaskStorage
impl AsyncStreamingHandler for InMemoryTaskStorage
Source§fn add_status_subscriber<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn add_status_subscriber<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
subscriber: Box<dyn Subscriber<TaskStatusUpdateEvent> + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Add a status update subscriber for a task
Source§fn add_artifact_subscriber<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn add_artifact_subscriber<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
subscriber: Box<dyn Subscriber<TaskArtifactUpdateEvent> + Send + Sync>,
) -> Pin<Box<dyn Future<Output = Result<String, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Add an artifact update subscriber for a task
Source§fn remove_subscription<'a, 'life0, 'async_trait>(
&'life0 self,
_subscription_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn remove_subscription<'a, 'life0, 'async_trait>(
&'life0 self,
_subscription_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Remove a specific subscription
Source§fn remove_task_subscribers<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn remove_task_subscribers<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Remove all subscribers for a task
Source§fn get_subscriber_count<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<usize, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_subscriber_count<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<usize, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get the number of active subscribers for a task
Source§fn broadcast_status_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
update: TaskStatusUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn broadcast_status_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
update: TaskStatusUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Broadcast a status update to all subscribers of a task
Source§fn broadcast_artifact_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
update: TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn broadcast_artifact_update<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
update: TaskArtifactUpdateEvent,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Broadcast an artifact update to all subscribers of a task
Source§fn status_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskStatusUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn status_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskStatusUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Create a stream of status updates for a task
Source§fn artifact_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskArtifactUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn artifact_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<TaskArtifactUpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Create a stream of artifact updates for a task
Source§fn combined_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn combined_update_stream<'a, 'life0, 'async_trait>(
&'life0 self,
_task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Create a combined stream of all updates for a task
Source§fn has_subscribers<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn has_subscribers<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Check if a task has any active subscribers
Source§fn validate_streaming_params<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn validate_streaming_params<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Validate streaming parameters
Source§fn start_task_streaming<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn start_task_streaming<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Pin<Box<dyn Stream<Item = Result<UpdateEvent, A2AError>> + Send>>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Start streaming for a task with automatic cleanup
Source§impl AsyncTaskManager for InMemoryTaskStorage
impl AsyncTaskManager for InMemoryTaskStorage
Source§fn create_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
context_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn create_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
context_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Create a new task
Source§fn update_task_status<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
state: TaskState,
message: Option<Message>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn update_task_status<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
state: TaskState,
message: Option<Message>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Update task status with an optional message to add to history
Source§fn task_exists<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn task_exists<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<bool, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Check if a task exists
Source§fn get_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
history_length: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
history_length: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get a task by ID with optional history
Source§fn cancel_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn cancel_task<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Cancel a task
Source§fn list_tasks<'a, 'life0, 'async_trait>(
&'life0 self,
_context_id: Option<&'a str>,
_limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn list_tasks<'a, 'life0, 'async_trait>(
&'life0 self,
_context_id: Option<&'a str>,
_limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<Task>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
List tasks with optional filtering
Source§fn get_task_metadata<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Map<String, Value>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn get_task_metadata<'a, 'life0, 'async_trait>(
&'life0 self,
task_id: &'a str,
) -> Pin<Box<dyn Future<Output = Result<Map<String, Value>, A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Get task metadata
Source§fn validate_task_params<'a, 'life0, 'async_trait>(
&'life0 self,
params: &'a TaskQueryParams,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn validate_task_params<'a, 'life0, 'async_trait>(
&'life0 self,
params: &'a TaskQueryParams,
) -> Pin<Box<dyn Future<Output = Result<(), A2AError>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
Validate task parameters
Source§impl Clone for InMemoryTaskStorage
impl Clone for InMemoryTaskStorage
Auto Trait Implementations§
impl Freeze for InMemoryTaskStorage
impl !RefUnwindSafe for InMemoryTaskStorage
impl Send for InMemoryTaskStorage
impl Sync for InMemoryTaskStorage
impl Unpin for InMemoryTaskStorage
impl !UnwindSafe for InMemoryTaskStorage
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
Mutably borrows from an owned value. Read more