pub struct AssetSource { /* private fields */ }Expand description
Where a world’s assets live, and where fetched ones are cached.
Implementations§
Source§impl AssetSource
impl AssetSource
Sourcepub fn local(base_dir: impl Into<PathBuf>) -> Self
pub fn local(base_dir: impl Into<PathBuf>) -> Self
A local world: relative URIs resolve against base_dir; absolute URLs still
fetch to a shared cache.
Sourcepub fn hosted(
base_dir: impl Into<PathBuf>,
base_url: Option<String>,
cache_dir: impl Into<PathBuf>,
) -> Self
pub fn hosted( base_dir: impl Into<PathBuf>, base_url: Option<String>, cache_dir: impl Into<PathBuf>, ) -> Self
A hosted world: base_url is the world’s directory URL (relative URIs resolve
against it); remote assets cache under cache_dir.
Sourcepub fn resolve(&self, uri: &str) -> Option<PathBuf>
pub fn resolve(&self, uri: &str) -> Option<PathBuf>
Resolve an asset URI to a readable local path, fetching + caching if remote.
Returns None if a remote fetch failed (the caller degrades gracefully —
e.g. falls back to a built-in mesh or a flat colour).
Sourcepub fn prefetch(&self, manifest: &WorldManifest)
pub fn prefetch(&self, manifest: &WorldManifest)
Download every remote asset in manifest into the cache (idempotent). Run on
a background thread before the main-thread GPU load so it only reads locally.
Auto Trait Implementations§
impl Freeze for AssetSource
impl RefUnwindSafe for AssetSource
impl Send for AssetSource
impl Sync for AssetSource
impl Unpin for AssetSource
impl UnsafeUnpin for AssetSource
impl UnwindSafe for AssetSource
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