pub struct RouterResponse {
pub id: RequestId,
pub inner: Result<McpResponse, JsonRpcError>,
}Expand description
Response type for the tower Service implementation
Fields§
§id: RequestIdThe JSON-RPC request ID this response corresponds to.
inner: Result<McpResponse, JsonRpcError>The MCP response or JSON-RPC error.
Implementations§
Source§impl RouterResponse
impl RouterResponse
Sourcepub fn is_error(&self) -> bool
pub fn is_error(&self) -> bool
Returns true if the response contains a JSON-RPC error.
Since tower-mcp services use Error = Infallible (errors are carried
inside the response, not in the Result), this method is useful for
middleware that needs to inspect whether a request failed – for example,
retry or circuit breaker middleware.
§Example
ⓘ
// Response-based retry predicate for tower-resilience or similar
fn is_retriable(response: &RouterResponse) -> bool {
response.is_error()
}Sourcepub fn into_jsonrpc(self) -> JsonRpcResponse
pub fn into_jsonrpc(self) -> JsonRpcResponse
Convert to JSON-RPC response
Trait Implementations§
Source§impl Clone for RouterResponse
impl Clone for RouterResponse
Source§fn clone(&self) -> RouterResponse
fn clone(&self) -> RouterResponse
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RouterResponse
impl RefUnwindSafe for RouterResponse
impl Send for RouterResponse
impl Sync for RouterResponse
impl Unpin for RouterResponse
impl UnsafeUnpin for RouterResponse
impl UnwindSafe for RouterResponse
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