Skip to main content

ResourceHandler

Trait ResourceHandler 

Source
pub trait ResourceHandler: Send + Sync {
    // Required methods
    fn uri_template(&self) -> &str;
    fn list(&self, cursor: Option<&str>) -> Result<ResourceList, ResourceError>;
    fn read(&self, uri: &str) -> Result<ResourceContent, ResourceError>;

    // Provided methods
    fn supports_subscribe(&self) -> bool { ... }
    fn matches(&self, uri: &str) -> bool { ... }
}
Expand description

Resource handler trait

Required Methods§

Source

fn uri_template(&self) -> &str

Get the URI template for this handler

Source

fn list(&self, cursor: Option<&str>) -> Result<ResourceList, ResourceError>

List available resources

Source

fn read(&self, uri: &str) -> Result<ResourceContent, ResourceError>

Read a specific resource

Provided Methods§

Source

fn supports_subscribe(&self) -> bool

Check if this handler supports subscriptions

Source

fn matches(&self, uri: &str) -> bool

Check if a URI matches this handler’s template

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§