Skip to main content

Peer

Trait Peer 

Source
pub trait Peer: Send + Sync {
    // Required method
    fn notify(
        &self,
        notification: Notification,
    ) -> Pin<Box<dyn Future<Output = Result<(), McpError>> + Send + '_>>;
}
Expand description

Trait for sending messages to the peer (client or server).

This trait abstracts over the transport layer, allowing the context to send notifications without knowing the underlying transport.

Required Methods§

Source

fn notify( &self, notification: Notification, ) -> Pin<Box<dyn Future<Output = Result<(), McpError>> + Send + '_>>

Send a notification to the peer.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Peer for NoOpPeer

Source§

impl<T> Peer for TransportPeer<T>
where T: Transport + 'static, <T as Transport>::Error: Into<McpError>,