pub struct McpResource {
pub uri: String,
pub mime_type: Option<String>,
pub text: Option<String>,
pub blob: Option<String>,
}Expand description
Resource reference in MCP.
Represents a resource that can be accessed through MCP, such as a file, URL, or other data source. Resources can contain either text or binary data.
§Fields
uri- Unique identifier for the resource (e.g., “file:///path/to/file”)mime_type- Optional MIME type of the resource contenttext- Text content (if the resource is text-based)blob- Binary content as base64 (if the resource is binary)
§Note
Either text or blob should be present, but not both.
§Example
ⓘ
// Text file resource
let text_resource = McpResource {
uri: "file:///docs/readme.txt".to_string(),
mime_type: Some("text/plain".to_string()),
text: Some("File contents here".to_string()),
blob: None,
};
// Binary file resource
let binary_resource = McpResource {
uri: "file:///images/photo.png".to_string(),
mime_type: Some("image/png".to_string()),
text: None,
blob: Some(base64_encoded_data),
};Fields§
§uri: StringUnique resource identifier (URI format)
mime_type: Option<String>MIME type of the resource content
text: Option<String>Text content (for text-based resources)
blob: Option<String>Binary content as base64 (for binary resources)
Trait Implementations§
Source§impl Clone for McpResource
impl Clone for McpResource
Source§fn clone(&self) -> McpResource
fn clone(&self) -> McpResource
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 moreSource§impl Debug for McpResource
impl Debug for McpResource
Source§impl<'de> Deserialize<'de> for McpResource
impl<'de> Deserialize<'de> for McpResource
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for McpResource
impl RefUnwindSafe for McpResource
impl Send for McpResource
impl Sync for McpResource
impl Unpin for McpResource
impl UnsafeUnpin for McpResource
impl UnwindSafe for McpResource
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