pub struct WebAssetLoader { /* private fields */ }Expand description
In-memory asset loader for the web target.
All loaded bytes live in a Mutex<HashMap> so the loader can
satisfy the AssetLoader: Send + Sync bound. Lookups are cheap
(single hash + clone of the byte vector). The cache is unbounded
— preloaded assets stay resident for the lifetime of the loader.
Implementations§
Source§impl WebAssetLoader
impl WebAssetLoader
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty loader. Use preload to fill
it before any synchronous load() call.
Sourcepub fn insert_raw(&self, key: impl Into<String>, bytes: Vec<u8>)
pub fn insert_raw(&self, key: impl Into<String>, bytes: Vec<u8>)
Insert raw bytes for key directly into the cache. Useful when
the app already has asset bytes in hand (e.g. via
include_bytes! for tiny bundled fonts) and doesn’t need a
fetch() round-trip.
Trait Implementations§
Source§impl AssetLoader for WebAssetLoader
impl AssetLoader for WebAssetLoader
Source§fn platform_name(&self) -> &'static str
fn platform_name(&self) -> &'static str
Get the platform name for this loader
Source§fn load_string(&self, path: &AssetPath) -> Result<String, PlatformError>
fn load_string(&self, path: &AssetPath) -> Result<String, PlatformError>
Load an asset as a UTF-8 string
Source§impl Debug for WebAssetLoader
impl Debug for WebAssetLoader
Source§impl Default for WebAssetLoader
impl Default for WebAssetLoader
Source§fn default() -> WebAssetLoader
fn default() -> WebAssetLoader
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for WebAssetLoader
impl RefUnwindSafe for WebAssetLoader
impl Send for WebAssetLoader
impl Sync for WebAssetLoader
impl Unpin for WebAssetLoader
impl UnsafeUnpin for WebAssetLoader
impl UnwindSafe for WebAssetLoader
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more