Skip to main content

Assets

Trait Assets 

Source
pub trait Assets:
    Send
    + Sync
    + 'static {
    // Required method
    fn read(&self, uri: &str) -> Result<Vec<u8>, String>;

    // Provided methods
    fn url(&self, uri: &str) -> Option<String> { ... }
    fn base(&self) -> Option<AssetBase> { ... }
}
Expand description

Reads the app’s bundled files (asset:/… URIs): from the app’s resources, or from the dev server during development. The engine reads the fonts it registers with it, and answers the app’s requests of asset:/ URLs (fetch) from it.

Required Methods§

Source

fn read(&self, uri: &str) -> Result<Vec<u8>, String>

The bytes of uri. Blocking: the engine calls it on its thread for the fonts it registers, and on a thread of the runtime’s blocking pool for the app’s requests (in WebAssembly on its thread).

Provided Methods§

Source

fn url(&self, uri: &str) -> Option<String>

Where uri is served, for files Assets::read does not have at hand: the engine downloads them from there with its network stack (the web page, which holds only the files it preloaded). None, the default, when read is the only way.

Source

fn base(&self) -> Option<AssetBase>

Where asset:/ URIs resolve, when it is a directory or a URL the image loader can read itself: the core’s image loads (svgs) then share the platform’s cache entries. None: through Assets::read.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§