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<AssetService, Error>
pub fn new( index_bytes: &[u8], io: Box<dyn AssetIo>, metrics_registry: Arc<MetricsRegistry>, manifest: Option<PackManifest>, ) -> Result<AssetService, Error>
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>(
&mut self,
type_name: &str,
decoder: impl AssetDecoder<A> + Send + Sync + 'static,
)where
A: Asset,
pub fn register_decoder<A>(
&mut self,
type_name: &str,
decoder: impl AssetDecoder<A> + Send + Sync + 'static,
)where
A: Asset,
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>(&mut self, uuid: &AssetUUID) -> Result<AssetHandle<A>, Error>where
A: Asset,
pub fn load<A>(&mut self, uuid: &AssetUUID) -> Result<AssetHandle<A>, Error>where
A: Asset,
Loads, decodes, and returns a typed handle to an asset.
Sourcepub fn load_raw(&mut self, uuid: &AssetUUID) -> Result<Vec<u8>, Error>
pub fn load_raw(&mut self, uuid: &AssetUUID) -> Result<Vec<u8>, Error>
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<(), Error>
pub fn reindex(&mut self, index_bytes: &[u8]) -> Result<(), Error>
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§
§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
§fn on_start(&mut self, ctx: &mut dyn AppContext)
fn on_start(&mut self, ctx: &mut dyn AppContext)
update. Apps install their theme / fonts here.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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.