Trait net::protocols::ProtocolHandler

source ·
pub trait ProtocolHandler: Send + Sync {
    // Required method
    fn load(
        &self,
        request: &mut Request,
        done_chan: &mut DoneChannel,
        context: &FetchContext,
    ) -> Pin<Box<dyn Future<Output = Response> + Send>>;

    // Provided method
    fn is_fetchable(&self) -> bool { ... }
}

Required Methods§

source

fn load( &self, request: &mut Request, done_chan: &mut DoneChannel, context: &FetchContext, ) -> Pin<Box<dyn Future<Output = Response> + Send>>

Triggers the load of a resource for this protocol and returns a future that will produce a Response. Even if the protocol is not backed by a http endpoint, it is recommended to a least provide:

  • A relevant status code.
  • A Content Type.

Provided Methods§

source

fn is_fetchable(&self) -> bool

Specify if resources served by that protocol can be retrieved with fetch() without no-cors mode to allow the caller direct access to the resource content.

Implementors§