pub enum DispatcherResult {
Success(Value),
Error(String),
}
Expand description
Result from the MCP dispatcher (success or error)
Middleware can inspect and modify this result in after_dispatch()
.
§Examples
use turul_http_mcp_server::middleware::DispatcherResult;
use serde_json::json;
let mut result = DispatcherResult::Success(json!({"output": "Hello"}));
// Middleware can transform successful responses
if let DispatcherResult::Success(ref mut value) = result {
if let Some(obj) = value.as_object_mut() {
obj.insert("timestamp".to_string(), json!("2025-10-04T12:00:00Z"));
}
}
Variants§
Success(Value)
Successful response (JSON-RPC result field)
Error(String)
Error response (will be converted to JSON-RPC error)
Implementations§
Source§impl DispatcherResult
impl DispatcherResult
Sourcepub fn is_success(&self) -> bool
pub fn is_success(&self) -> bool
Check if result is successful
Sourcepub fn success_mut(&mut self) -> Option<&mut Value>
pub fn success_mut(&mut self) -> Option<&mut Value>
Get mutable success value (if any)
Trait Implementations§
Source§impl Clone for DispatcherResult
impl Clone for DispatcherResult
Source§fn clone(&self) -> DispatcherResult
fn clone(&self) -> DispatcherResult
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 DispatcherResult
impl RefUnwindSafe for DispatcherResult
impl Send for DispatcherResult
impl Sync for DispatcherResult
impl Unpin for DispatcherResult
impl UnwindSafe for DispatcherResult
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