Skip to main content

ResourceHandler

Trait ResourceHandler 

Source
pub trait ResourceHandler:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list(
        &self,
    ) -> Pin<Box<dyn Future<Output = Vec<ResourceDef>> + Send + '_>>;
    fn read(
        &self,
        uri: &str,
    ) -> Pin<Box<dyn Future<Output = Result<ResourceContentDef, String>> + Send + '_>>;
    fn subscribe(
        &self,
        uri: &str,
    ) -> Pin<Box<dyn Future<Output = Result<Receiver<ResourceContentDef>, String>> + Send + '_>>;
}
Expand description

Resource handler trait

Implement this trait to handle resource operations.

Required Methods§

Source

fn list(&self) -> Pin<Box<dyn Future<Output = Vec<ResourceDef>> + Send + '_>>

List available resources

Source

fn read( &self, uri: &str, ) -> Pin<Box<dyn Future<Output = Result<ResourceContentDef, String>> + Send + '_>>

Read a resource

Source

fn subscribe( &self, uri: &str, ) -> Pin<Box<dyn Future<Output = Result<Receiver<ResourceContentDef>, String>> + Send + '_>>

Subscribe to resource updates (returns a stream receiver)

Implementors§