Peer

Struct Peer 

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

Source

pub async fn complete( &self, params: CompleteRequestParam, ) -> Result<CompleteResult, ServiceError>

Source

pub async fn set_level( &self, params: SetLevelRequestParam, ) -> Result<(), ServiceError>

Source

pub async fn get_prompt( &self, params: GetPromptRequestParam, ) -> Result<GetPromptResult, ServiceError>

Source

pub async fn list_prompts( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListPromptsResult, ServiceError>

Source

pub async fn list_resources( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListResourcesResult, ServiceError>

Source

pub async fn list_resource_templates( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListResourceTemplatesResult, ServiceError>

Source

pub async fn read_resource( &self, params: ReadResourceRequestParam, ) -> Result<ReadResourceResult, ServiceError>

Source

pub async fn subscribe( &self, params: SubscribeRequestParam, ) -> Result<(), ServiceError>

Source

pub async fn unsubscribe( &self, params: UnsubscribeRequestParam, ) -> Result<(), ServiceError>

Source

pub async fn call_tool( &self, params: CallToolRequestParam, ) -> Result<CallToolResult, ServiceError>

Source

pub async fn list_tools( &self, params: Option<PaginatedRequestParam>, ) -> Result<ListToolsResult, ServiceError>

Source

pub async fn notify_cancelled( &self, params: CancelledNotificationParam, ) -> Result<(), ServiceError>

Source

pub async fn notify_progress( &self, params: ProgressNotificationParam, ) -> Result<(), ServiceError>

Source

pub async fn notify_initialized(&self) -> Result<(), ServiceError>

Source

pub async fn notify_roots_list_changed(&self) -> Result<(), ServiceError>

Source§

impl Peer<RoleClient>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 completed
  • argument_name - Name of the argument being completed
  • current_value - Current partial value of the argument
  • context - Optional context with previously resolved arguments
§Returns

CompletionInfo with suggestions for the specified prompt argument

Source

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 completed
  • argument_name - Name of the URI parameter being completed
  • current_value - Current partial value of the parameter
  • context - Optional context with previously resolved arguments
§Returns

CompletionInfo with suggestions for the specified resource URI argument

Source

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.

Source

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>

Source§

impl<R> Peer<R>
where R: ServiceRole,

Source

pub async fn send_notification( &self, notification: <R as ServiceRole>::Not, ) -> Result<(), ServiceError>

Source

pub async fn send_request( &self, request: <R as ServiceRole>::Req, ) -> Result<<R as ServiceRole>::PeerResp, ServiceError>

Source

pub async fn send_cancellable_request( &self, request: <R as ServiceRole>::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>

Source

pub async fn send_request_with_option( &self, request: <R as ServiceRole>::Req, options: PeerRequestOptions, ) -> Result<RequestHandle<R>, ServiceError>

Source

pub fn peer_info(&self) -> Option<&<R as ServiceRole>::PeerInfo>

Source

pub fn set_peer_info(&self, info: <R as ServiceRole>::PeerInfo)

Source

pub fn is_transport_closed(&self) -> bool

Trait Implementations§

Source§

impl<R> Clone for Peer<R>

Source§

fn clone(&self) -> Peer<R>

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<R> Debug for Peer<R>
where R: ServiceRole,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<C> FromContextPart<C> for Peer<RoleServer>

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> !UnwindSafe for Peer<R>

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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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