Struct fyrox_resource::untyped::UntypedResource
source · pub struct UntypedResource(pub Arc<Mutex<ResourceHeader>>);
Expand description
Untyped resource is a universal way of storing arbitrary resource types. Internally it wraps
ResourceState
in a Arc<Mutex<>
so the untyped resource becomes shareable. In most of the
cases you don’t need to deal with untyped resources, use typed Resource
wrapper instead.
Untyped resource could be useful in cases when you need to collect a set resources of different
types in a single collection and do something with them.
§Default state
Default state of every untyped resource is ResourceState::LoadError
with a warning message,
that the resource is in default state. This is a trade-off to prevent wrapping internals into
Option
, that in some cases could lead to convoluted code with lots of unwrap
s and state
assumptions.
Tuple Fields§
§0: Arc<Mutex<ResourceHeader>>
Implementations§
source§impl UntypedResource
impl UntypedResource
sourcepub fn new_pending(kind: ResourceKind, type_uuid: Uuid) -> Self
pub fn new_pending(kind: ResourceKind, type_uuid: Uuid) -> Self
Creates new untyped resource in pending state using the given path and type uuid.
sourcepub fn new_ok<T>(kind: ResourceKind, data: T) -> Selfwhere
T: ResourceData,
pub fn new_ok<T>(kind: ResourceKind, data: T) -> Selfwhere
T: ResourceData,
Creates new untyped resource in ok (fully loaded) state using the given data of any type, that
implements ResourceData
trait.
sourcepub fn new_load_error(
kind: ResourceKind,
error: LoadError,
type_uuid: Uuid
) -> Self
pub fn new_load_error( kind: ResourceKind, error: LoadError, type_uuid: Uuid ) -> Self
Creates new untyped resource in error state.
sourcepub fn is_loading(&self) -> bool
pub fn is_loading(&self) -> bool
Returns true if the resource is still loading.
sourcepub fn is_embedded(&self) -> bool
pub fn is_embedded(&self) -> bool
Returns true if the resource is procedural (its data is generated at runtime, not stored in an external file).
sourcepub fn kind(&self) -> ResourceKind
pub fn kind(&self) -> ResourceKind
Returns path of the untyped resource.
sourcepub fn set_kind(&self, new_kind: ResourceKind)
pub fn set_kind(&self, new_kind: ResourceKind)
Set a new path for the untyped resource.
sourcepub fn try_cast<T>(&self) -> Option<Resource<T>>where
T: TypedResourceData,
pub fn try_cast<T>(&self) -> Option<Resource<T>>where
T: TypedResourceData,
Tries to cast untyped resource to a particular type.
sourcepub fn commit(&self, state: ResourceState)
pub fn commit(&self, state: ResourceState)
Changes ResourceState::Pending state to ResourceState::Ok(data) with given data
.
Additionally it wakes all futures.
sourcepub fn commit_ok<T: ResourceData>(&self, data: T)
pub fn commit_ok<T: ResourceData>(&self, data: T)
Changes internal state to ResourceState::Ok
sourcepub fn commit_error<E: ResourceLoadError>(&self, error: E)
pub fn commit_error<E: ResourceLoadError>(&self, error: E)
Changes internal state to ResourceState::LoadError
.
Trait Implementations§
source§impl Clone for UntypedResource
impl Clone for UntypedResource
source§impl Debug for UntypedResource
impl Debug for UntypedResource
source§impl Default for UntypedResource
impl Default for UntypedResource
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 Future for UntypedResource
impl Future for UntypedResource
§type Output = Result<UntypedResource, LoadError>
type Output = Result<UntypedResource, LoadError>
source§impl Hash for UntypedResource
impl Hash for UntypedResource
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 PartialEq for UntypedResource
impl PartialEq for UntypedResource
source§impl Reflect for UntypedResource
impl Reflect for UntypedResource
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 Visit for UntypedResource
impl Visit for UntypedResource
impl Eq for UntypedResource
Auto Trait Implementations§
impl !RefUnwindSafe for UntypedResource
impl Send for UntypedResource
impl Sync for UntypedResource
impl Unpin for UntypedResource
impl !UnwindSafe for UntypedResource
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