pub struct AssetService { /* private fields */ }Expand description
The asset management service.
Provides on-demand asset loading through a VFS → IO → Decode → Store pipeline.
Registered in ServiceRegistry and accessed by game code via AppContext.
Implementations§
Source§impl AssetService
impl AssetService
Sourcepub fn new(
index_bytes: &[u8],
io: Box<dyn AssetIo>,
metrics_registry: Arc<MetricsRegistry>,
manifest: Option<PackManifest>,
) -> Result<Self>
pub fn new( index_bytes: &[u8], io: Box<dyn AssetIo>, metrics_registry: Arc<MetricsRegistry>, manifest: Option<PackManifest>, ) -> Result<Self>
Creates a new AssetService.
When manifest is Some, both load and load_raw re-hash the
bytes returned by the underlying AssetIo against the recorded
BLAKE3 digest and refuse to proceed on mismatch.
Sourcepub fn vfs(&self) -> &VirtualFileSystem
pub fn vfs(&self) -> &VirtualFileSystem
Returns a reference to the underlying VFS for metadata enumeration (asset browser) and direct UUID lookup.
Sourcepub fn register_decoder<A: Asset>(
&mut self,
type_name: &str,
decoder: impl AssetDecoder<A> + Send + Sync + 'static,
)
pub fn register_decoder<A: Asset>( &mut self, type_name: &str, decoder: impl AssetDecoder<A> + Send + Sync + 'static, )
Registers a decoder for a specific asset type.
Sourcepub fn register_inventory_decoders(&mut self)
pub fn register_inventory_decoders(&mut self)
Walks inventory::iter::<DecoderRegistration> and runs each entry’s
register fn. Use this once after construction to pull in every
decoder declared via inventory::submit! — currently texture and
font. Audio and mesh decoders are intentionally explicit (see
decoders/audio and decoders/mesh for the rationale).
Sourcepub fn load<A: Asset>(&mut self, uuid: &AssetUUID) -> Result<AssetHandle<A>>
pub fn load<A: Asset>(&mut self, uuid: &AssetUUID) -> Result<AssetHandle<A>>
Loads, decodes, and returns a typed handle to an asset.
Sourcepub fn load_raw(&mut self, uuid: &AssetUUID) -> Result<Vec<u8>>
pub fn load_raw(&mut self, uuid: &AssetUUID) -> Result<Vec<u8>>
Loads an asset’s raw bytes via the VFS → IO path, skipping the
decoder. Used by scene loading where the bytes are then decoded by a
SerializationService strategy rather than an AssetDecoder<A>.
Sourcepub fn invalidate(&mut self, uuid: &AssetUUID) -> bool
pub fn invalidate(&mut self, uuid: &AssetUUID) -> bool
Drops the cached handle for uuid across every typed storage.
Subsequent load::<A>() calls re-run the IO + decoder pipeline.
Returns true if any storage held this UUID.
Outstanding clones of the previously-cached AssetHandle<A> keep the
old asset alive until they themselves drop — by design (in-flight
readers don’t see a half-loaded replacement).
Sourcepub fn reindex(&mut self, index_bytes: &[u8]) -> Result<()>
pub fn reindex(&mut self, index_bytes: &[u8]) -> Result<()>
Atomically replaces the inner VirtualFileSystem with a freshly
decoded one. Cached handles are kept; callers should invalidate
any UUID whose underlying bytes changed (the editor’s hot-reload
pump only invokes reindex when files were added or removed —
pure in-place modifications go through invalidate).
Sourcepub fn load_count(&self) -> usize
pub fn load_count(&self) -> usize
Returns the total number of assets loaded so far.
Sourcepub fn cached_type_count(&self) -> usize
pub fn cached_type_count(&self) -> usize
Returns the number of cached asset type storages.
Auto Trait Implementations§
impl Freeze for AssetService
impl !RefUnwindSafe for AssetService
impl Send for AssetService
impl Sync for AssetService
impl Unpin for AssetService
impl UnsafeUnpin for AssetService
impl !UnwindSafe for AssetService
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more