pub struct AssetRegistry { /* private fields */ }Expand description
Central type-erased registry that maps numeric IDs to asset slots.
The registry does not know the concrete type of the assets it stores;
type safety is enforced at the AssetHandle / AssetId boundary.
External code normally interacts with the registry through AssetServer.
Implementations§
Source§impl AssetRegistry
impl AssetRegistry
Sourcepub fn alloc(&mut self, type_id: TypeId, path: AssetPath) -> u64
pub fn alloc(&mut self, type_id: TypeId, path: AssetPath) -> u64
Allocate a new slot and return its ID.
Sourcepub fn id_for_path(&self, path: &AssetPath) -> Option<u64>
pub fn id_for_path(&self, path: &AssetPath) -> Option<u64>
Look up the ID already assigned to path, if any.
Sourcepub fn load_state(&self, id: u64) -> LoadState
pub fn load_state(&self, id: u64) -> LoadState
Return the current LoadState for the given raw ID.
Sourcepub fn mark_loading(&mut self, id: u64)
pub fn mark_loading(&mut self, id: u64)
Mark a slot as LoadState::Loading.
Sourcepub fn store<T: Asset>(&mut self, id: u64, value: T, mtime: Option<SystemTime>)
pub fn store<T: Asset>(&mut self, id: u64, value: T, mtime: Option<SystemTime>)
Store a successfully loaded value.
Sourcepub fn mark_failed(&mut self, id: u64, message: String)
pub fn mark_failed(&mut self, id: u64, message: String)
Mark a slot as failed.
Sourcepub fn get<T: Asset>(&mut self, id: u64) -> Option<Arc<T>>
pub fn get<T: Asset>(&mut self, id: u64) -> Option<Arc<T>>
Try to read a stored value, downcasting to T.
Trait Implementations§
Source§impl Debug for AssetRegistry
impl Debug for AssetRegistry
Auto Trait Implementations§
impl Freeze for AssetRegistry
impl !RefUnwindSafe for AssetRegistry
impl Send for AssetRegistry
impl Sync for AssetRegistry
impl Unpin for AssetRegistry
impl UnsafeUnpin for AssetRegistry
impl !UnwindSafe for AssetRegistry
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.