Enum rg3d_resource::ResourceState [−][src]
pub enum ResourceState<T: ResourceData, E: ResourceLoadError> {
Pending {
path: PathBuf,
wakers: Vec<Waker>,
},
LoadError {
path: PathBuf,
error: Option<Arc<E>>,
},
Ok(T),
}
Expand description
Resource could be in three possible states:
- Pending - it is loading.
- LoadError - an error has occurred during the load.
- Ok - resource is fully loaded and ready to use.
Why it is so complex? Short answer: asynchronous loading. Long answer: when you loading a scene you expect it to be loaded as fast as possible, use all available power of the CPU. To achieve that each resource ideally should be loaded on separate core of the CPU, but since this is asynchronous, we must have the ability to track the state of the resource.
Variants
Pending
Fields
path: PathBuf
A path to load resource from.
Resource is loading from external resource or in the queue to load.
LoadError
Fields
path: PathBuf
A path at which it was impossible to load the resource.
An error has occurred during the load.
Ok(T)
Actual resource data when it is fully loaded.
Implementations
Creates new resource in pending state.
Changes ResourceState::Pending state to ResourceState::Ok(data) with given data
.
Additionally it wakes all futures.
Trait Implementations
Auto Trait Implementations
impl<T, E> RefUnwindSafe for ResourceState<T, E> where
E: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, E> Send for ResourceState<T, E>
impl<T, E> Sync for ResourceState<T, E> where
T: Sync,
impl<T, E> Unpin for ResourceState<T, E> where
T: Unpin,
impl<T, E> UnwindSafe for ResourceState<T, E> where
E: RefUnwindSafe,
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.