pub struct ResourceManager { /* private fields */ }
Expand description
Resource manager for registering and accessing resources
Implementations§
Source§impl ResourceManager
impl ResourceManager
Sourcepub fn register_resource(
&self,
resource: Resource,
content_provider: impl Fn() -> Result<Vec<ResourceContent>> + Send + Sync + 'static,
)
pub fn register_resource( &self, resource: Resource, content_provider: impl Fn() -> Result<Vec<ResourceContent>> + Send + Sync + 'static, )
Register a new resource
Sourcepub async fn list_resources(
&self,
cursor: Option<String>,
) -> (Vec<Resource>, Option<String>)
pub async fn list_resources( &self, cursor: Option<String>, ) -> (Vec<Resource>, Option<String>)
Get registered resources with pagination
Sourcepub async fn get_resource_content(
&self,
uri: &str,
) -> Result<Vec<ResourceContent>>
pub async fn get_resource_content( &self, uri: &str, ) -> Result<Vec<ResourceContent>>
Get a specific resource’s content
Sourcepub fn register_template(
&self,
template: ResourceTemplate,
expander: impl Fn(String, HashMap<String, String>) -> Result<String> + Send + Sync + 'static,
)
pub fn register_template( &self, template: ResourceTemplate, expander: impl Fn(String, HashMap<String, String>) -> Result<String> + Send + Sync + 'static, )
Register a template
Sourcepub fn register_completion_provider(
&self,
template_uri: &str,
provider: impl Fn(String, String, Option<String>) -> Result<Vec<CompletionItem>> + Send + Sync + 'static,
)
pub fn register_completion_provider( &self, template_uri: &str, provider: impl Fn(String, String, Option<String>) -> Result<Vec<CompletionItem>> + Send + Sync + 'static, )
Register a completion provider for a template parameter
Sourcepub async fn get_completions(
&self,
template_uri: &str,
parameter: &str,
value: Option<String>,
) -> Result<Vec<CompletionItem>>
pub async fn get_completions( &self, template_uri: &str, parameter: &str, value: Option<String>, ) -> Result<Vec<CompletionItem>>
Get completion items for a template parameter
Sourcepub async fn list_templates(
&self,
cursor: Option<String>,
) -> (Vec<ResourceTemplate>, Option<String>)
pub async fn list_templates( &self, cursor: Option<String>, ) -> (Vec<ResourceTemplate>, Option<String>)
Get all registered templates with pagination
Sourcepub async fn subscribe(&self, client_id: &str, uri: &str) -> Result<()>
pub async fn subscribe(&self, client_id: &str, uri: &str) -> Result<()>
Subscribe to resource updates
Sourcepub async fn unsubscribe(&self, client_id: &str, uri: &str) -> Result<()>
pub async fn unsubscribe(&self, client_id: &str, uri: &str) -> Result<()>
Unsubscribe from resource updates
Sourcepub async fn update_resource(
&self,
resource: Resource,
content_provider: impl Fn() -> Result<Vec<ResourceContent>> + Send + Sync + 'static,
) -> Result<()>
pub async fn update_resource( &self, resource: Resource, content_provider: impl Fn() -> Result<Vec<ResourceContent>> + Send + Sync + 'static, ) -> Result<()>
Update a resource and notify subscribers
Sourcepub fn subscribe_to_updates(&self) -> Receiver<String>
pub fn subscribe_to_updates(&self) -> Receiver<String>
Get a channel for subscribing to resource updates
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceManager
impl !RefUnwindSafe for ResourceManager
impl Send for ResourceManager
impl Sync for ResourceManager
impl Unpin for ResourceManager
impl !UnwindSafe for ResourceManager
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