Struct ResourceDatabase

Source
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

Source

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.

Source

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 ResourceDatabases will cause panics.

Source§

impl ResourceDatabase

Source

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.

Source

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 ResourceDatabases will cause panics.

Source§

impl ResourceDatabase

Source

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.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.