pub trait ClientHandler: Send + Sync {
// Provided methods
fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_shutdown<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn pong<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn create_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_method: &'life2 str,
_params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn list_roots<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn elicit<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_task_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskPayloadResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn list_tasks<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_cursor: Option<Cursor>,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<CancelTaskResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn notification<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_notification: ServerNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Handler trait that client implementers must implement.
Each client connection will have its own instance of the implementation.
All methods take &self to allow concurrent request handling.
Implementations should use interior mutability (Arc<Mutex<_>>, RwLock, etc.)
for any mutable state.
Provided Methods§
Sourcefn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_connect<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called after the initialization handshake completes.
Sourcefn on_shutdown<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_shutdown<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when the connection is being closed
Sourcefn pong<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pong<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Respond to a ping request from the server
Sourcefn create_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_method: &'life2 str,
_params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn create_message<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_method: &'life2 str,
_params: CreateMessageParams,
) -> Pin<Box<dyn Future<Output = Result<CreateMessageResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Request the server to create a model message.
Sourcefn list_roots<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_roots<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
) -> Pin<Box<dyn Future<Output = Result<ListRootsResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request the server to list roots.
Sourcefn elicit<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn elicit<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_params: ElicitRequestParams,
) -> Pin<Box<dyn Future<Output = Result<ElicitResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Request the server to elicit user input.
Sourcefn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the state of a task.
Sourcefn get_task_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskPayloadResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_task_payload<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<GetTaskPayloadResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieve the result of a completed task.
Sourcefn list_tasks<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_cursor: Option<Cursor>,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_tasks<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_cursor: Option<Cursor>,
) -> Pin<Box<dyn Future<Output = Result<ListTasksResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List tasks.
Sourcefn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<CancelTaskResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn cancel_task<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_task_id: String,
) -> Pin<Box<dyn Future<Output = Result<CancelTaskResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cancel a task by ID.
Sourcefn notification<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_notification: ServerNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn notification<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ClientCtx,
_notification: ServerNotification,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Handle a notification sent from the server
The default implementation ignores the notification. Implementations can override this method to react to server-initiated notifications.
Implementations on Foreign Types§
impl ClientHandler for ()
Default no-op implementation of ClientHandler for unit type