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: CompleteRequestParams, ) -> Result<CompleteResult, ServiceError>
pub async fn set_level( &self, params: SetLevelRequestParams, ) -> Result<(), ServiceError>
pub async fn get_prompt( &self, params: GetPromptRequestParams, ) -> Result<GetPromptResult, ServiceError>
pub async fn list_prompts( &self, params: Option<PaginatedRequestParams>, ) -> Result<ListPromptsResult, ServiceError>
pub async fn list_resources( &self, params: Option<PaginatedRequestParams>, ) -> Result<ListResourcesResult, ServiceError>
pub async fn list_resource_templates( &self, params: Option<PaginatedRequestParams>, ) -> Result<ListResourceTemplatesResult, ServiceError>
pub async fn read_resource( &self, params: ReadResourceRequestParams, ) -> Result<ReadResourceResult, ServiceError>
pub async fn subscribe( &self, params: SubscribeRequestParams, ) -> Result<(), ServiceError>
pub async fn unsubscribe( &self, params: UnsubscribeRequestParams, ) -> Result<(), ServiceError>
pub async fn call_tool( &self, params: CallToolRequestParams, ) -> Result<CallToolResult, ServiceError>
pub async fn list_tools( &self, params: Option<PaginatedRequestParams>, ) -> 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.
Source§impl Peer<RoleServer>
impl Peer<RoleServer>
Sourcepub fn supports_sampling_tools(&self) -> bool
pub fn supports_sampling_tools(&self) -> bool
Check if the client supports sampling tools capability.
pub async fn create_message( &self, params: CreateMessageRequestParams, ) -> Result<CreateMessageResult, ServiceError>
pub async fn list_roots(&self) -> Result<ListRootsResult, 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_logging_message( &self, params: LoggingMessageNotificationParam, ) -> Result<(), ServiceError>
pub async fn notify_resource_updated( &self, params: ResourceUpdatedNotificationParam, ) -> Result<(), ServiceError>
pub async fn notify_resource_list_changed(&self) -> Result<(), ServiceError>
pub async fn notify_tool_list_changed(&self) -> Result<(), ServiceError>
pub async fn notify_prompt_list_changed(&self) -> Result<(), ServiceError>
Source§impl<R> Peer<R>where
R: ServiceRole,
impl<R> Peer<R>where
R: ServiceRole,
pub async fn send_notification( &self, notification: <R as ServiceRole>::Not, ) -> Result<(), ServiceError>
pub async fn send_request( &self, request: <R as ServiceRole>::Req, ) -> Result<<R as ServiceRole>::PeerResp, ServiceError>
pub async fn send_cancellable_request( &self, request: <R as ServiceRole>::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>
pub async fn send_request_with_option( &self, request: <R as ServiceRole>::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>
pub fn peer_info(&self) -> Option<&<R as ServiceRole>::PeerInfo>
pub fn set_peer_info(&self, info: <R as ServiceRole>::PeerInfo)
pub fn is_transport_closed(&self) -> bool
Trait Implementations§
Source§impl<R> Debug for Peer<R>where
R: ServiceRole,
impl<R> Debug for Peer<R>where
R: ServiceRole,
Source§impl<C> FromContextPart<C> for Peer<RoleServer>where
C: AsRequestContext,
impl<C> FromContextPart<C> for Peer<RoleServer>where
C: AsRequestContext,
fn from_context_part(context: &mut C) -> Result<Peer<RoleServer>, ErrorData>
Auto Trait Implementations§
impl<R> Freeze for Peer<R>
impl<R> !RefUnwindSafe for Peer<R>
impl<R> Send for Peer<R>
impl<R> Sync for Peer<R>
impl<R> Unpin for Peer<R>
impl<R> UnsafeUnpin for Peer<R>
impl<R> !UnwindSafe for Peer<R>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more