Struct distill_loader::loader::Loader[][src]

pub struct Loader { /* fields omitted */ }

Loads and tracks lifetimes of asset data.

Implementations

impl Loader[src]

pub fn new(io: Box<dyn LoaderIO>) -> Loader[src]

pub fn new_with_handle_allocator(
    io: Box<dyn LoaderIO>,
    handle_allocator: Arc<dyn HandleAllocator>
) -> Loader
[src]

pub fn with_serde_context<R>(
    &self,
    tx: &Sender<RefOp>,
    mut f: impl FnMut() -> R
) -> R
[src]

pub fn get_load(&self, id: AssetUuid) -> Option<LoadHandle>[src]

Returns the load handle for the asset with the given UUID, if present.

This will only return Some(..) if there has been a previous call to Loader::add_ref.

Parameters

  • id: UUID of the asset.

pub fn get_load_info(&self, load: LoadHandle) -> Option<LoadInfo>[src]

Returns the number of references to an asset.

Note: The information is true at the time the LoadInfo is retrieved. The actual number of references may change.

Parameters

  • load_handle: ID allocated by Loader to track loading of the asset.

pub fn get_load_status(&self, load: LoadHandle) -> LoadStatus[src]

Returns the asset load status.

Parameters

  • load: ID allocated by Loader to track loading of the asset.

pub fn add_ref<U: Into<AssetUuid>>(&self, id: U) -> LoadHandle[src]

Adds a reference to an asset and returns its LoadHandle.

If the asset is already loaded, this returns the existing LoadHandle. If it is not loaded, this allocates a new LoadHandle and returns that.

Parameters

  • id: UUID of the asset.

pub fn add_ref_indirect(&self, id: IndirectIdentifier) -> LoadHandle[src]

Adds a reference to an indirect id and returns its LoadHandle with LoadHandle::is_indirect set to true.

Parameters

  • id: IndirectIdentifier for the load.

pub fn get_asset_type(&self, load: LoadHandle) -> Option<AssetTypeId>[src]

Returns the AssetTypeId for the currently loaded asset of the provided load handle.

Parameters

  • load: ID allocated by Loader to track loading of the asset.

pub fn remove_ref(&self, load: LoadHandle)[src]

Removes a reference to an asset.

Parameters

  • load_handle: ID allocated by Loader to track loading of the asset.

pub fn process(
    &mut self,
    asset_storage: &dyn AssetStorage,
    resolver: &dyn IndirectionResolver
) -> Result<()>
[src]

Processes pending load operations.

Load operations include:

Parameters

  • asset_storage: Storage for all assets of all asset types.

pub fn indirection_table(&self) -> IndirectionTable[src]

Returns a reference to the loader's IndirectionTable.

When a user fetches an asset by LoadHandle, implementors of AssetStorage should resolve LoadHandles where LoadHandle::is_indirect returns true by using IndirectionTable::resolve. IndirectionTable is Send + Sync + Clone so that it can be retrieved once at startup, then stored in implementors of AssetStorage.

pub fn invalidate_assets(&self, assets: &[AssetUuid])[src]

Invalidates the data & metadata of the provided asset IDs.

This causes the asset data to be reloaded.

pub fn invalidate_paths(&self, paths: &[PathBuf])[src]

Invalidates indirect identifiers that may match the provided paths.

This may cause indirect handles to resolve to new assets.

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.