Skip to main content

ResourceLoader

Trait ResourceLoader 

pub trait ResourceLoader:
    Send
    + Sync
    + 'static {
    // Required method
    fn load(
        &self,
        request: ResourceRequest,
        options: ResourceLoadOptions,
        cx: &mut ResourceContext<'_>,
    ) -> bool;

    // Provided method
    fn status(&self, _path: &str) -> LoadingStatus { ... }
}
Expand description

Trait for loading resources asynchronously or from various sources.

Loaders are invoked in chain-of-responsibility order when a resource is requested. Return true to indicate the request was handled (no further loaders are tried), or false to continue to the next loader.

Required Methods§

fn load( &self, request: ResourceRequest, options: ResourceLoadOptions, cx: &mut ResourceContext<'_>, ) -> bool

Attempt to load a resource.

request describes what to load, while options describes how to load it. Return true if this loader handled the request, false to try the next loader.

Provided Methods§

fn status(&self, _path: &str) -> LoadingStatus

Query the loading status of a resource path.

Default implementation returns NotLoaded — override to track async loading progress.

Implementors§

§

impl ResourceLoader for FileResourceLoader

Available on non-crate feature tokio only.