Struct fyrox_resource::Resource
source · pub struct Resource<T>where
T: TypedResourceData,{ /* private fields */ }
Expand description
A resource of particular data type. It is a typed wrapper around UntypedResource
which
does type checks at runtime.
§Default State
Default state of the resource will be ResourceState::Ok
with T::default
.
Implementations§
source§impl<T> Resource<T>where
T: TypedResourceData,
impl<T> Resource<T>where
T: TypedResourceData,
source§impl<T> Resource<T>where
T: TypedResourceData,
impl<T> Resource<T>where
T: TypedResourceData,
sourcepub fn new_pending(kind: ResourceKind) -> Self
pub fn new_pending(kind: ResourceKind) -> Self
Creates new resource in pending state.
sourcepub fn new_ok(kind: ResourceKind, data: T) -> Self
pub fn new_ok(kind: ResourceKind, data: T) -> Self
Creates new resource in ok state (fully loaded).
sourcepub fn new_load_error(kind: ResourceKind, error: LoadError) -> Self
pub fn new_load_error(kind: ResourceKind, error: LoadError) -> Self
Creates new resource in error state.
sourcepub fn into_untyped(self) -> UntypedResource ⓘ
pub fn into_untyped(self) -> UntypedResource ⓘ
Converts self to internal value.
sourcepub fn state(&self) -> ResourceHeaderGuard<'_, T>
pub fn state(&self) -> ResourceHeaderGuard<'_, T>
Locks internal mutex provides access to the state.
sourcepub fn try_acquire_state(&self) -> Option<ResourceHeaderGuard<'_, T>>
pub fn try_acquire_state(&self) -> Option<ResourceHeaderGuard<'_, T>>
Tries to lock internal mutex provides access to the state.
pub fn header(&self) -> MutexGuard<'_, ResourceHeader>
sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns true if the resource is still loading.
sourcepub fn is_failed_to_load(&self) -> bool
pub fn is_failed_to_load(&self) -> bool
Returns true if the resource is failed to load.
sourcepub fn kind(&self) -> ResourceKind
pub fn kind(&self) -> ResourceKind
Returns kind of the resource.
sourcepub fn set_path(&mut self, new_kind: ResourceKind)
pub fn set_path(&mut self, new_kind: ResourceKind)
Sets a new kind of the resource.
sourcepub fn data_ref(&self) -> ResourceDataRef<'_, T>
pub fn data_ref(&self) -> ResourceDataRef<'_, T>
Allows you to obtain reference to the resource data.
§Panic
An attempt to use method result will panic if resource is not loaded yet, or
there was load error. Usually this is ok because normally you’d chain this call
like this resource.await?.data_ref()
. Every resource implements Future trait
and it returns Result, so if you’ll await future then you’ll get Result, so
call to data_ref
will be fine.
Trait Implementations§
source§impl<T> Clone for Resource<T>where
T: TypedResourceData,
impl<T> Clone for Resource<T>where
T: TypedResourceData,
source§impl<T> Default for Resource<T>where
T: TypedResourceData,
impl<T> Default for Resource<T>where
T: TypedResourceData,
source§impl<T> From<UntypedResource> for Resource<T>where
T: TypedResourceData,
impl<T> From<UntypedResource> for Resource<T>where
T: TypedResourceData,
source§fn from(untyped: UntypedResource) -> Self
fn from(untyped: UntypedResource) -> Self
source§impl<T> Future for Resource<T>where
T: TypedResourceData,
impl<T> Future for Resource<T>where
T: TypedResourceData,
source§impl<T> Hash for Resource<T>where
T: TypedResourceData,
impl<T> Hash for Resource<T>where
T: TypedResourceData,
source§impl<T> Into<UntypedResource> for Resource<T>where
T: TypedResourceData,
impl<T> Into<UntypedResource> for Resource<T>where
T: TypedResourceData,
source§fn into(self) -> UntypedResource ⓘ
fn into(self) -> UntypedResource ⓘ
source§impl<T> PartialEq for Resource<T>where
T: TypedResourceData,
impl<T> PartialEq for Resource<T>where
T: TypedResourceData,
source§impl<T> Reflect for Resource<T>
impl<T> Reflect for Resource<T>
fn type_name(&self) -> &'static str
fn doc(&self) -> &'static str
fn fields_info(&self, func: &mut dyn FnMut(&[FieldInfo<'_, '_>]))
fn into_any(self: Box<Self>) -> Box<dyn Any>
fn set( &mut self, value: Box<dyn Reflect> ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_any(&self, func: &mut dyn FnMut(&dyn Any))
fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))
fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))
fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))
fn fields(&self, func: &mut dyn FnMut(&[&dyn Reflect]))
fn fields_mut(&mut self, func: &mut dyn FnMut(&mut [&mut dyn Reflect]))
fn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))
fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>) )
source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>,
func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>)
)
fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>) )
#[reflect(setter = ..)]
or falls back to
Reflect::field_mut
fn as_array(&self, func: &mut dyn FnMut(Option<&(dyn ReflectArray + 'static)>))
fn as_array_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectArray + 'static)>) )
fn as_list(&self, func: &mut dyn FnMut(Option<&(dyn ReflectList + 'static)>))
fn as_list_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectList + 'static)>) )
fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&(dyn ReflectInheritableVariable + 'static)>) )
fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectInheritableVariable + 'static)>) )
fn as_hash_map( &self, func: &mut dyn FnMut(Option<&(dyn ReflectHashMap + 'static)>) )
fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut (dyn ReflectHashMap + 'static)>) )
source§impl<T: TypedResourceData> TypeUuidProvider for Resource<T>
impl<T: TypedResourceData> TypeUuidProvider for Resource<T>
source§impl<T> Visit for Resource<T>where
T: TypedResourceData,
impl<T> Visit for Resource<T>where
T: TypedResourceData,
impl<T> Eq for Resource<T>where
T: TypedResourceData,
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Resource<T>
impl<T> Send for Resource<T>
impl<T> Sync for Resource<T>where
T: Sync,
impl<T> Unpin for Resource<T>where
T: Unpin,
impl<T> !UnwindSafe for Resource<T>
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
source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn map<U, F>(self, f: F) -> Map<Self, F>
fn map<U, F>(self, f: F) -> Map<Self, F>
§fn map_into<U>(self) -> MapInto<Self, U>
fn map_into<U>(self) -> MapInto<Self, U>
§fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
fn then<Fut, F>(self, f: F) -> Then<Self, Fut, F>
f
. Read more§fn left_future<B>(self) -> Either<Self, B>
fn left_future<B>(self) -> Either<Self, B>
§fn right_future<A>(self) -> Either<A, Self>
fn right_future<A>(self) -> Either<A, Self>
§fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
fn into_stream(self) -> IntoStream<Self>where
Self: Sized,
§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
§fn flatten_stream(self) -> FlattenStream<Self>
fn flatten_stream(self) -> FlattenStream<Self>
§fn fuse(self) -> Fuse<Self>where
Self: Sized,
fn fuse(self) -> Fuse<Self>where
Self: Sized,
poll
will never again be called once it has
completed. This method can be used to turn any Future
into a
FusedFuture
. Read more§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
§fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>where
Self: Sized + UnwindSafe,
§fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
fn remote_handle(self) -> (Remote<Self>, RemoteHandle<Self::Output>)where
Self: Sized,
()
on completion and sends
its output to another future on a separate task. Read more§fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
fn boxed<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a>>
§fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Future<Output = Self::Output> + 'a>>where
Self: Sized + 'a,
§fn unit_error(self) -> UnitError<Self>where
Self: Sized,
fn unit_error(self) -> UnitError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = ()
>.§fn never_error(self) -> NeverError<Self>where
Self: Sized,
fn never_error(self) -> NeverError<Self>where
Self: Sized,
Future<Output = T>
into a
TryFuture<Ok = T, Error = Never
>.source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
§type IntoFuture = F
type IntoFuture = F
source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>) )
fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>) )
fn get_resolve_path<T, 'p>(
&self,
path: &'p str,
func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>)
)where
T: Reflect,
fn get_resolve_path_mut<T, 'p>(
&mut self,
path: &'p str,
func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>)
)where
T: Reflect,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.§impl<F, T, E> TryFuture for F
impl<F, T, E> TryFuture for F
§impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
impl<Fut> TryFutureExt for Futwhere
Fut: TryFuture + ?Sized,
§fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
fn flatten_sink<Item>(self) -> FlattenSink<Self, Self::Ok>where
Self::Ok: Sink<Item, Error = Self::Error>,
Self: Sized,
Sink
]. Read more