pub struct Resource {
pub uri: Uri,
pub name: String,
pub descr: Option<String>,
pub mime: Option<String>,
pub size: Option<usize>,
pub title: Option<String>,
pub annotations: Option<Annotations>,
pub icons: Option<Vec<Icon>>,
pub meta: Option<Value>,
}Expand description
Represents a known resource that the server is capable of reading.
See the schema for details
Fields§
§uri: UriThe URI of this resource.
name: StringA human-readable name for this resource.
descr: Option<String>A description of what this resource represents.
mime: Option<String>The MIME type of this resource, if known.
size: Option<usize>The resource size in bytes, if known
title: Option<String>Intended for UI and end-user contexts - optimized to be human-readable and easily understood, even by those unfamiliar with domain-specific terminology.
If not provided, the name should be used for display (except for Tool,
where annotations.title should be given precedence over using name, if present).
annotations: Option<Annotations>Optional annotations for the client.
icons: Option<Vec<Icon>>Optional set of sized icons that the client can display in a user interface.
Clients that support rendering icons MUST support at least the following MIME types:
image/png- PNG images (safe, universal compatibility)image/jpeg(andimage/jpg) - JPEG images (safe, universal compatibility)
Clients that support rendering icons SHOULD also support:
image/svg+xml- SVG images (scalable but requires security precautions)image/webp- WebP images (modern, efficient format)
meta: Option<Value>Metadata reserved by MCP for protocol-level metadata.
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn with_descr(self, description: impl Into<String>) -> Self
pub fn with_descr(self, description: impl Into<String>) -> Self
Sets a description for a resource
Sourcepub fn with_annotations<F>(self, config: F) -> Self
pub fn with_annotations<F>(self, config: F) -> Self
Sets annotations for the client
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Sets a title for a resource
Sourcepub fn with_icons(&mut self, icons: impl IntoIterator<Item = Icon>) -> &mut Self
pub fn with_icons(&mut self, icons: impl IntoIterator<Item = Icon>) -> &mut Self
Sets the Resource icons
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Resource
impl<'de> Deserialize<'de> for Resource
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<Resource> for ResourceLink
impl From<Resource> for ResourceLink
Auto Trait Implementations§
impl Freeze for Resource
impl RefUnwindSafe for Resource
impl Send for Resource
impl Sync for Resource
impl Unpin for Resource
impl UnwindSafe for Resource
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)