pub struct HandleLoadState<A: Asset> { /* private fields */ }Expand description
Combined handle and load state for convenient asset status checking.
This type wraps an asset handle together with its current loading state, allowing users to check both validity and load progress in one place.
§Example
use goud_engine::assets::{Asset, AssetHandle, AssetState, HandleLoadState};
struct Texture;
impl Asset for Texture {}
// Simulate an asset that's loading
let handle: AssetHandle<Texture> = AssetHandle::new(0, 1);
let state = HandleLoadState::new(handle, AssetState::Loading { progress: 0.5 });
assert!(state.is_loading());
assert_eq!(state.progress(), Some(0.5));
// When loaded
let state = HandleLoadState::new(handle, AssetState::Loaded);
assert!(state.is_ready());Implementations§
Source§impl<A: Asset> HandleLoadState<A>
impl<A: Asset> HandleLoadState<A>
Sourcepub fn new(handle: AssetHandle<A>, state: AssetState) -> Self
pub fn new(handle: AssetHandle<A>, state: AssetState) -> Self
Creates a new handle load state.
Sourcepub fn handle(&self) -> &AssetHandle<A>
pub fn handle(&self) -> &AssetHandle<A>
Returns a reference to the handle.
Sourcepub fn state(&self) -> &AssetState
pub fn state(&self) -> &AssetState
Returns a reference to the asset state.
Sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns true if the asset is currently loading.
Sourcepub fn into_handle(self) -> AssetHandle<A>
pub fn into_handle(self) -> AssetHandle<A>
Consumes self and returns the inner handle.
Sourcepub fn set_state(&mut self, state: AssetState)
pub fn set_state(&mut self, state: AssetState)
Updates the state.
Trait Implementations§
Source§impl<A: Clone + Asset> Clone for HandleLoadState<A>
impl<A: Clone + Asset> Clone for HandleLoadState<A>
Source§fn clone(&self) -> HandleLoadState<A>
fn clone(&self) -> HandleLoadState<A>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A: Asset> Default for HandleLoadState<A>
impl<A: Asset> Default for HandleLoadState<A>
impl<A: Asset> StructuralPartialEq for HandleLoadState<A>
Auto Trait Implementations§
impl<A> Freeze for HandleLoadState<A>
impl<A> RefUnwindSafe for HandleLoadState<A>where
A: RefUnwindSafe,
impl<A> Send for HandleLoadState<A>
impl<A> Sync for HandleLoadState<A>
impl<A> Unpin for HandleLoadState<A>where
A: Unpin,
impl<A> UnsafeUnpin for HandleLoadState<A>
impl<A> UnwindSafe for HandleLoadState<A>where
A: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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>
Converts
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>
Converts
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 moreSource§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
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().