Skip to main content

AssetSource

Trait AssetSource 

Source
pub trait AssetSource:
    Send
    + Sync
    + 'static {
    // Required methods
    fn read(&self, path: &str) -> Option<Vec<u8>>;
    fn list(&self, dir: &str) -> Vec<String>;
    fn name(&self) -> &str;
}
Expand description

A single layer of the overlay filesystem.

Implementations must be cheaply cloneable-by-Arc: crate::Assets shares sources behind Arc<dyn AssetSource> for zero-cost cloning.

Required Methods§

Source

fn read(&self, path: &str) -> Option<Vec<u8>>

Return the bytes at path if this layer provides it.

Source

fn list(&self, dir: &str) -> Vec<String>

Return the immediate entries of dir (files and subdirectory names, without the dir prefix). Empty if dir does not exist on this layer.

Source

fn name(&self) -> &str

Diagnostic-only name (shown in parse errors). The empty string is fine for anonymous / test sources.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§