pub trait Service<R: ServiceRole>:
Send
+ Sync
+ 'static {
// Required methods
fn handle_request(
&self,
request: R::PeerReq,
context: RequestContext<R>,
) -> impl Future<Output = Result<R::Resp, McpError>> + Send + '_;
fn handle_notification(
&self,
notification: R::PeerNot,
context: NotificationContext<R>,
) -> impl Future<Output = Result<(), McpError>> + Send + '_;
fn get_info(&self) -> R::Info;
}Available on crate features
client or server only.Required Methods§
fn handle_request( &self, request: R::PeerReq, context: RequestContext<R>, ) -> impl Future<Output = Result<R::Resp, McpError>> + Send + '_
fn handle_notification( &self, notification: R::PeerNot, context: NotificationContext<R>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
fn get_info(&self) -> R::Info
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<R: ServiceRole> Service<R> for Box<dyn DynService<R>>
impl<R: ServiceRole> Service<R> for Box<dyn DynService<R>>
fn handle_request( &self, request: R::PeerReq, context: RequestContext<R>, ) -> impl Future<Output = Result<R::Resp, McpError>> + Send + '_
fn handle_notification( &self, notification: R::PeerNot, context: NotificationContext<R>, ) -> impl Future<Output = Result<(), McpError>> + Send + '_
fn get_info(&self) -> R::Info
Implementors§
impl<H: ClientHandler> Service<RoleClient> for H
Available on crate feature
client only.impl<H: ServerHandler> Service<RoleServer> for H
Available on crate feature
server only.impl<S> Service<RoleServer> for Router<S>where
S: ServerHandler,
Available on crate feature
server only.impl<S, R: ServiceRole> Service<R> for TowerHandler<S, R>
Available on crate feature
tower only.