pub struct Resource {
pub uri: String,
pub name: Option<String>,
pub title: Option<String>,
pub description: Option<String>,
pub mime_type: Option<String>,
pub handler: ResourceHandler,
}Expand description
A resource definition for the resources/list response
Represents a single resource with its metadata. The handler is called when the client requests the resource via resources/read.
Fields§
§uri: StringUnique resource URI
name: Option<String>Resource name (e.g. filename)
title: Option<String>Human-readable title for display
description: Option<String>Description of the resource
mime_type: Option<String>Optional MIME type
handler: ResourceHandlerHandler to read resource content when requested
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn builder(
uri: impl Into<String>,
handler: ResourceHandler,
) -> ResourceBuilder
pub fn builder( uri: impl Into<String>, handler: ResourceHandler, ) -> ResourceBuilder
Sourcepub fn to_list_item(&self) -> Value
pub fn to_list_item(&self) -> Value
Convert to MCP resources/list item format
Returns a JSON object compatible with MCP protocol:
{
"uri": "file:///...",
"name": "main.rs",
"title": "Optional title",
"description": "Optional description",
"mimeType": "text/x-rust"
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnsafeUnpin for Resource
impl UnwindSafe for Resource
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