Trait ResourceLoader

Source
pub trait ResourceLoader: BaseResourceLoader {
    // Required methods
    fn extensions(&self) -> &[&str];
    fn data_type_uuid(&self) -> Uuid;
    fn load(
        &self,
        path: PathBuf,
        io: Arc<dyn ResourceIo>,
    ) -> Pin<Box<dyn Future<Output = Result<LoaderPayload, LoadError>> + Send>>;

    // Provided methods
    fn supports_extension(&self, ext: &str) -> bool { ... }
    fn try_load_import_settings(
        &self,
        resource_path: PathBuf,
        io: Arc<dyn ResourceIo>,
    ) -> Pin<Box<dyn Future<Output = Option<Box<dyn BaseImportOptions>>>>> { ... }
    fn default_import_options(&self) -> Option<Box<dyn BaseImportOptions>> { ... }
}
Expand description

Trait for resource loading.

Required Methods§

Source

fn extensions(&self) -> &[&str]

Returns a list of file extensions supported by the loader. Resource manager will use this list to pick the correct resource loader when the user requests a resource.

Source

fn data_type_uuid(&self) -> Uuid

Must return a type uuid of the resource data type.

Source

fn load( &self, path: PathBuf, io: Arc<dyn ResourceIo>, ) -> Pin<Box<dyn Future<Output = Result<LoaderPayload, LoadError>> + Send>>

Loads or reloads a resource.

Provided Methods§

Source

fn supports_extension(&self, ext: &str) -> bool

Checks if the given extension is supported by this loader. Comparison is case-insensitive.

Source

fn try_load_import_settings( &self, resource_path: PathBuf, io: Arc<dyn ResourceIo>, ) -> Pin<Box<dyn Future<Output = Option<Box<dyn BaseImportOptions>>>>>

Tries to load import settings for a resource.

Source

fn default_import_options(&self) -> Option<Box<dyn BaseImportOptions>>

Returns default import options for the resource.

Implementors§