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§
Sourcefn load(
&self,
request: ResourceRequest,
options: ResourceLoadOptions,
cx: &mut ResourceContext<'_>,
) -> bool
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§
Sourcefn status(&self, _path: &str) -> LoadingStatus
fn status(&self, _path: &str) -> LoadingStatus
Query the loading status of a resource path.
Default implementation returns NotLoaded — override to track async loading progress.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl ResourceLoader for FileResourceLoader
Available on non-crate feature
tokio only.