pub struct Peer<R>where
R: ServiceRole,{ /* private fields */ }Expand description
An interface to fetch the remote client or server
For general purpose, call Peer::send_request or Peer::send_notification to send message to remote peer.
To create a cancellable request, call Peer::send_request_with_option.
Implementations§
Source§impl Peer<RoleClient>
impl Peer<RoleClient>
pub async fn complete( &self, params: CompleteRequestParam, ) -> Result<CompleteResult, ServiceError>
pub async fn set_level( &self, params: SetLevelRequestParam, ) -> Result<(), ServiceError>
pub async fn get_prompt( &self, params: GetPromptRequestParam, ) -> Result<GetPromptResult, ServiceError>
pub async fn list_prompts( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListPromptsResult, ServiceError>
pub async fn list_resources( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListResourcesResult, ServiceError>
pub async fn list_resource_templates( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListResourceTemplatesResult, ServiceError>
pub async fn read_resource( &self, params: ReadResourceRequestParam, ) -> Result<ReadResourceResult, ServiceError>
pub async fn subscribe( &self, params: SubscribeRequestParam, ) -> Result<(), ServiceError>
pub async fn unsubscribe( &self, params: UnsubscribeRequestParam, ) -> Result<(), ServiceError>
pub async fn call_tool( &self, params: CallToolRequestParam, ) -> Result<CallToolResult, ServiceError>
pub async fn list_tools( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListToolsResult, ServiceError>
pub async fn notify_cancelled( &self, params: CancelledNotificationParam, ) -> Result<(), ServiceError>
pub async fn notify_progress( &self, params: ProgressNotificationParam, ) -> Result<(), ServiceError>
pub async fn notify_initialized(&self) -> Result<(), ServiceError>
pub async fn notify_roots_list_changed(&self) -> Result<(), ServiceError>
Source§impl Peer<RoleClient>
impl Peer<RoleClient>
Sourcepub async fn list_all_tools(&self) -> Result<Vec<Tool>, ServiceError>
pub async fn list_all_tools(&self) -> Result<Vec<Tool>, ServiceError>
A wrapper method for Peer<RoleClient>::list_tools.
This function will call Peer<RoleClient>::list_tools multiple times until all tools are listed.
Sourcepub async fn list_all_prompts(&self) -> Result<Vec<Prompt>, ServiceError>
pub async fn list_all_prompts(&self) -> Result<Vec<Prompt>, ServiceError>
A wrapper method for Peer<RoleClient>::list_prompts.
This function will call Peer<RoleClient>::list_prompts multiple times until all prompts are listed.
Sourcepub async fn list_all_resources(
&self,
) -> Result<Vec<Annotated<RawResource>>, ServiceError>
pub async fn list_all_resources( &self, ) -> Result<Vec<Annotated<RawResource>>, ServiceError>
A wrapper method for Peer<RoleClient>::list_resources.
This function will call Peer<RoleClient>::list_resources multiple times until all resources are listed.
Sourcepub async fn list_all_resource_templates(
&self,
) -> Result<Vec<Annotated<RawResourceTemplate>>, ServiceError>
pub async fn list_all_resource_templates( &self, ) -> Result<Vec<Annotated<RawResourceTemplate>>, ServiceError>
A wrapper method for Peer<RoleClient>::list_resource_templates.
This function will call Peer<RoleClient>::list_resource_templates multiple times until all resource templates are listed.
Sourcepub async fn complete_prompt_argument(
&self,
prompt_name: impl Into<String>,
argument_name: impl Into<String>,
current_value: impl Into<String>,
context: Option<CompletionContext>,
) -> Result<CompletionInfo, ServiceError>
pub async fn complete_prompt_argument( &self, prompt_name: impl Into<String>, argument_name: impl Into<String>, current_value: impl Into<String>, context: Option<CompletionContext>, ) -> Result<CompletionInfo, ServiceError>
Convenient method to get completion suggestions for a prompt argument
§Arguments
prompt_name- Name of the prompt being completedargument_name- Name of the argument being completedcurrent_value- Current partial value of the argumentcontext- Optional context with previously resolved arguments
§Returns
CompletionInfo with suggestions for the specified prompt argument
Sourcepub async fn complete_resource_argument(
&self,
uri_template: impl Into<String>,
argument_name: impl Into<String>,
current_value: impl Into<String>,
context: Option<CompletionContext>,
) -> Result<CompletionInfo, ServiceError>
pub async fn complete_resource_argument( &self, uri_template: impl Into<String>, argument_name: impl Into<String>, current_value: impl Into<String>, context: Option<CompletionContext>, ) -> Result<CompletionInfo, ServiceError>
Convenient method to get completion suggestions for a resource URI argument
§Arguments
uri_template- URI template pattern being completedargument_name- Name of the URI parameter being completedcurrent_value- Current partial value of the parametercontext- Optional context with previously resolved arguments
§Returns
CompletionInfo with suggestions for the specified resource URI argument
Sourcepub async fn complete_prompt_simple(
&self,
prompt_name: impl Into<String>,
argument_name: impl Into<String>,
current_value: impl Into<String>,
) -> Result<Vec<String>, ServiceError>
pub async fn complete_prompt_simple( &self, prompt_name: impl Into<String>, argument_name: impl Into<String>, current_value: impl Into<String>, ) -> Result<Vec<String>, ServiceError>
Simple completion for a prompt argument without context
This is a convenience wrapper around complete_prompt_argument for
simple completion scenarios that don’t require context awareness.
Sourcepub async fn complete_resource_simple(
&self,
uri_template: impl Into<String>,
argument_name: impl Into<String>,
current_value: impl Into<String>,
) -> Result<Vec<String>, ServiceError>
pub async fn complete_resource_simple( &self, uri_template: impl Into<String>, argument_name: impl Into<String>, current_value: impl Into<String>, ) -> Result<Vec<String>, ServiceError>
Simple completion for a resource URI argument without context
This is a convenience wrapper around complete_resource_argument for
simple completion scenarios that don’t require context awareness.