pub struct McpRouter { /* private fields */ }Expand description
Dispatches MCP request/notification envelopes against a session.
Implementations§
Source§impl McpRouter
impl McpRouter
Sourcepub fn new(session: McpSession) -> Self
pub fn new(session: McpSession) -> Self
Creates a router bound to session.
Sourcepub fn session(&self) -> &McpSession
pub fn session(&self) -> &McpSession
Returns the underlying session.
Sourcepub fn session_mut(&mut self) -> &mut McpSession
pub fn session_mut(&mut self) -> &mut McpSession
Returns a mutable reference to the underlying session.
Sourcepub fn handle_expr(&mut self, cx: &mut Cx, expr: Expr) -> Result<Option<Expr>>
pub fn handle_expr(&mut self, cx: &mut Cx, expr: Expr) -> Result<Option<Expr>>
Decodes one envelope Expr, routes it, and encodes the final reply.
Sourcepub fn handle_exprs(&mut self, cx: &mut Cx, expr: Expr) -> Result<Vec<Expr>>
pub fn handle_exprs(&mut self, cx: &mut Cx, expr: Expr) -> Result<Vec<Expr>>
Decodes one envelope Expr, routes it, and encodes every reply
(notifications and the final response) in order.
Sourcepub fn handle(
&mut self,
cx: &mut Cx,
envelope: McpEnvelope,
) -> Result<RouterReply>
pub fn handle( &mut self, cx: &mut Cx, envelope: McpEnvelope, ) -> Result<RouterReply>
Routes envelope and returns only the final response or error reply.
Sourcepub fn handle_many(
&mut self,
cx: &mut Cx,
envelope: McpEnvelope,
) -> Result<Vec<McpEnvelope>>
pub fn handle_many( &mut self, cx: &mut Cx, envelope: McpEnvelope, ) -> Result<Vec<McpEnvelope>>
Routes envelope and returns every reply it produces, in order.
Auto Trait Implementations§
impl !RefUnwindSafe for McpRouter
impl !UnwindSafe for McpRouter
impl Freeze for McpRouter
impl Send for McpRouter
impl Sync for McpRouter
impl Unpin for McpRouter
impl UnsafeUnpin for McpRouter
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
Mutably borrows from an owned value. Read more