pub struct Json<T>(pub T);Expand description
Wrapper for returning JSON-serialized data from a tool handler.
Automatically serializes the inner value to pretty-printed JSON.
§Example
ⓘ
use turbomcp_core::response::Json;
#[derive(Serialize)]
struct UserData {
name: String,
age: u32,
}
async fn get_user() -> impl IntoToolResponse {
Json(UserData {
name: "Alice".into(),
age: 30,
})
}Tuple Fields§
§0: TTrait Implementations§
Source§impl<T> IntoToolResponse for Json<T>where
T: Serialize,
impl<T> IntoToolResponse for Json<T>where
T: Serialize,
Source§fn into_tool_response(self) -> CallToolResult
fn into_tool_response(self) -> CallToolResult
Convert this type into a
CallToolResultSource§impl<T> IntoToolResult for Json<T>where
T: Serialize,
impl<T> IntoToolResult for Json<T>where
T: Serialize,
Source§fn into_tool_result(self) -> ToolResult
fn into_tool_result(self) -> ToolResult
Convert this value into a
ToolResult.Auto Trait Implementations§
impl<T> Freeze for Json<T>where
T: Freeze,
impl<T> RefUnwindSafe for Json<T>where
T: RefUnwindSafe,
impl<T> Send for Json<T>where
T: Send,
impl<T> Sync for Json<T>where
T: Sync,
impl<T> Unpin for Json<T>where
T: Unpin,
impl<T> UnsafeUnpin for Json<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Json<T>where
T: UnwindSafe,
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