pub struct ResourceDatabase {
pub chunks: SparseArray<'static, ChunkData>,
pub sprite_chunks: SparseArray<'static, SpriteChunkData>,
/* private fields */
}
Expand description
The resource database.
Game code should mostly use this for the find_*
and get_*
functions to
query for assets, which implement the relevant logic for each asset type.
Fields§
§chunks: SparseArray<'static, ChunkData>
The regular chunks currently loaded in-memory. Loaded via
ResourceLoader
, usually by functions making use of an asset.
sprite_chunks: SparseArray<'static, SpriteChunkData>
The sprite chunks currently loaded in-memory. Loaded via
ResourceLoader
, usually by functions making use of an asset.
Implementations§
Source§impl ResourceDatabase
impl ResourceDatabase
Sourcepub fn find_audio_clip(&self, name: &str) -> Option<AudioClipHandle>
pub fn find_audio_clip(&self, name: &str) -> Option<AudioClipHandle>
Returns a AudioClipHandle
if the database contains a AudioClipAsset
with this name. Cache this, and use ResourceDatabase::get_audio_clip
to access the actual asset at runtime.
Sourcepub fn get_audio_clip(&self, handle: AudioClipHandle) -> &AudioClipAsset
pub fn get_audio_clip(&self, handle: AudioClipHandle) -> &AudioClipAsset
Returns the AudioClipAsset
behind a handle previously queried with ResourceDatabase::find_audio_clip
. Note that reusing handles between separate ResourceDatabase
s will cause panics.
Source§impl ResourceDatabase
impl ResourceDatabase
Sourcepub fn find_sprite(&self, name: &str) -> Option<SpriteHandle>
pub fn find_sprite(&self, name: &str) -> Option<SpriteHandle>
Returns a SpriteHandle
if the database contains a SpriteAsset
with this name. Cache this, and use ResourceDatabase::get_sprite
to access the actual asset at runtime.
Sourcepub fn get_sprite(&self, handle: SpriteHandle) -> &SpriteAsset
pub fn get_sprite(&self, handle: SpriteHandle) -> &SpriteAsset
Returns the SpriteAsset
behind a handle previously queried with ResourceDatabase::find_sprite
. Note that reusing handles between separate ResourceDatabase
s will cause panics.
Source§impl ResourceDatabase
impl ResourceDatabase
Sourcepub fn largest_chunk_source(&self) -> u64
pub fn largest_chunk_source(&self) -> u64
Returns the longest source bytes length of all the chunks, i.e. the minimum amount of staging memory required to be able to load any chunk in this database.