pub struct Resource {
pub info: Resource,
pub handler: Box<dyn ResourceHandler>,
pub template: Option<ResourceTemplate>,
pub enabled: bool,
}
Expand description
A registered resource with its handler
Fields§
§info: Resource
Information about the resource
handler: Box<dyn ResourceHandler>
Handler that implements the resource’s functionality
template: Option<ResourceTemplate>
Optional template for parameterized resources
enabled: bool
Whether the resource is currently enabled
Implementations§
Source§impl Resource
impl Resource
Sourcepub fn new<H>(info: ResourceInfo, handler: H) -> Selfwhere
H: ResourceHandler + 'static,
pub fn new<H>(info: ResourceInfo, handler: H) -> Selfwhere
H: ResourceHandler + 'static,
Create a new static resource
§Arguments
info
- Information about the resourcehandler
- Implementation of the resource’s functionality
Sourcepub fn with_template<H>(template: ResourceTemplate, handler: H) -> Selfwhere
H: ResourceHandler + 'static,
pub fn with_template<H>(template: ResourceTemplate, handler: H) -> Selfwhere
H: ResourceHandler + 'static,
Create a new templated resource
§Arguments
template
- Template for the resourcehandler
- Implementation of the resource’s functionality
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if the resource is enabled
Sourcepub async fn read(
&self,
uri: &str,
params: &HashMap<String, String>,
) -> McpResult<Vec<ResourceContents>>
pub async fn read( &self, uri: &str, params: &HashMap<String, String>, ) -> McpResult<Vec<ResourceContents>>
Sourcepub async fn list(&self) -> McpResult<Vec<ResourceInfo>>
pub async fn list(&self) -> McpResult<Vec<ResourceInfo>>
List resources from this handler
Sourcepub async fn unsubscribe(&self, uri: &str) -> McpResult<()>
pub async fn unsubscribe(&self, uri: &str) -> McpResult<()>
Unsubscribe from resource changes
Sourcepub fn matches_uri(&self, uri: &str) -> bool
pub fn matches_uri(&self, uri: &str) -> bool
Check if this resource matches the given URI
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 !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