Trait ResourceProtocol

pub trait ResourceProtocol {
    // Required method
    fn handle(
        &self,
        url: &KanziStr,
        protocol: &KanziStr,
        hostname: &KanziStr,
        path: &KanziStr,
    ) -> Result<Either<Resource, Box<dyn ResourceLoadTask>>, Error>;
}
Expand description

Use this trait to implement the protocol for loading resources.

Required Methods§

fn handle( &self, url: &KanziStr, protocol: &KanziStr, hostname: &KanziStr, path: &KanziStr, ) -> Result<Either<Resource, Box<dyn ResourceLoadTask>>, Error>

Type definition for the protocol handler of the load function. The load function takes a resource URL and creates either a new resource or a load task that creates a new resource.

§Arguments
  • url - The full URL of the resource in the form of protocol://hostname[:port]/path.
  • protocol - Extracted protocol part of the resource URL.
  • hostname - Extracted hostname part of the resource URL.
  • path - Extracted path part of the resource URL.
§Returns

Either an already loaded resource, or a task for loading a resource.

Implementors§