Trait ResourceHandler

Source
pub trait ResourceHandler: Send + Sync {
    // Required methods
    fn read<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        uri: &'life1 str,
        params: &'life2 HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = McpResult<Vec<ResourceContents>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn list<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = McpResult<Vec<ResourceInfo>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        uri: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn unsubscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        uri: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Trait for implementing resource handlers

Required Methods§

Source

fn read<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, uri: &'life1 str, params: &'life2 HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = McpResult<Vec<ResourceContents>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Read the content of a resource

§Arguments
  • uri - URI of the resource to read
  • params - Additional parameters for the resource
§Returns

Result containing the resource content or an error

Source

fn list<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = McpResult<Vec<ResourceInfo>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

List all available resources

§Returns

Result containing a list of available resources or an error

Provided Methods§

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, uri: &'life1 str, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to changes in a resource (optional)

§Arguments
  • uri - URI of the resource to subscribe to
§Returns

Result indicating success or an error

Source

fn unsubscribe<'life0, 'life1, 'async_trait>( &'life0 self, uri: &'life1 str, ) -> Pin<Box<dyn Future<Output = McpResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unsubscribe from changes in a resource (optional)

§Arguments
  • uri - URI of the resource to unsubscribe from
§Returns

Result indicating success or an error

Implementors§