Skip to main content

ResourceHandler

Trait ResourceHandler 

Source
pub trait ResourceHandler: Send + Sync {
    // Required method
    fn read(&self) -> BoxFuture<'_, Result<ReadResourceResult>>;

    // Provided methods
    fn read_with_context(
        &self,
        _ctx: RequestContext,
    ) -> BoxFuture<'_, Result<ReadResourceResult>> { ... }
    fn uses_context(&self) -> bool { ... }
}
Expand description

Resource handler trait - the core abstraction for resource reading

Required Methods§

Source

fn read(&self) -> BoxFuture<'_, Result<ReadResourceResult>>

Read the resource contents

Provided Methods§

Source

fn read_with_context( &self, _ctx: RequestContext, ) -> BoxFuture<'_, Result<ReadResourceResult>>

Read the resource with request context for progress/cancellation support

The default implementation ignores the context and calls read. Override this to receive progress/cancellation context.

Source

fn uses_context(&self) -> bool

Returns true if this handler uses context (for optimization)

Implementors§