Skip to main content

AssetLoader

Trait AssetLoader 

Source
pub trait AssetLoader: Send + Sync {
    // Required method
    fn load(&self, name: &str) -> Result<Asset, AssetError>;

    // Provided method
    fn hash(&self, _name: &str) -> u128 { ... }
}
Expand description

Pluggable backend for resolving named asset bindings (images, brushes, tile features, …). Names that start with tile. are by convention tile-scoped — the host rebinds them per render.

hash returns a stable content/identity hash the evaluator folds into every consuming node’s cache key, so changes in a bound asset invalidate caches automatically. Implementations may return 0 if the binding never changes (document-scoped, fixed disk file, etc.).

Required Methods§

Source

fn load(&self, name: &str) -> Result<Asset, AssetError>

Provided Methods§

Source

fn hash(&self, _name: &str) -> u128

Content/identity hash for cache invalidation. The default of 0 is safe for assets that never change for the lifetime of a loader (typical for in-memory image / brush banks).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§