InMemoryTaskStorage

Struct InMemoryTaskStorage 

Source
pub struct InMemoryTaskStorage { /* private fields */ }
Expand description

Simple in-memory task storage for testing and example purposes

Implementations§

Source§

impl InMemoryTaskStorage

Source

pub fn new() -> Self

Create a new empty task storage

Source

pub fn with_push_sender( push_sender: impl PushNotificationSender + 'static, ) -> Self

Create a new task storage with a custom push notification sender

Source

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)

Source

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

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Send notification for task artifact update
Source§

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Start streaming for a task with automatic cleanup
Source§

fn stop_task_streaming<'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,

Stop all streaming for a task
Source§

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,

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,

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,

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,

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,

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,

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,

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,

Validate task parameters
Source§

fn get_task_validated<'a, 'life0, 'async_trait>( &'life0 self, params: &'a TaskQueryParams, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Get task with validation
Source§

fn cancel_task_validated<'a, 'life0, 'async_trait>( &'life0 self, params: &'a TaskIdParams, ) -> Pin<Box<dyn Future<Output = Result<Task, A2AError>> + Send + 'async_trait>>
where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,

Cancel task with validation
Source§

impl Clone for InMemoryTaskStorage

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for InMemoryTaskStorage

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,