Struct fyrox::asset::manager::ResourceManagerState
source · pub struct ResourceManagerState {
pub loaders: ResourceLoadersContainer,
pub event_broadcaster: ResourceEventBroadcaster,
pub constructors_container: ResourceConstructorContainer,
pub built_in_resources: HashMap<PathBuf, UntypedResource, BuildHasherDefault<FxHasher>>,
pub resource_io: Arc<dyn ResourceIo>,
/* private fields */
}
Expand description
See module docs.
Fields§
§loaders: ResourceLoadersContainer
A set of resource loaders. Use this field to register your own resource loader.
event_broadcaster: ResourceEventBroadcaster
Event broadcaster can be used to “subscribe” for events happening inside the container.
constructors_container: ResourceConstructorContainer
A container for resource constructors.
built_in_resources: HashMap<PathBuf, UntypedResource, BuildHasherDefault<FxHasher>>
A set of built-in resources, that will be used to resolve references on deserialization.
resource_io: Arc<dyn ResourceIo>
The resource acccess interface
Implementations§
source§impl ResourceManagerState
impl ResourceManagerState
sourcepub fn set_resource_io(&mut self, resource_io: Arc<dyn ResourceIo>)
pub fn set_resource_io(&mut self, resource_io: Arc<dyn ResourceIo>)
Set the IO source that the resource manager should use when loading assets
sourcepub fn set_watcher(&mut self, watcher: Option<FileSystemWatcher>)
pub fn set_watcher(&mut self, watcher: Option<FileSystemWatcher>)
Sets resource watcher which will track any modifications in file system and forcing the manager to reload changed resources. By default there is no watcher, since it may be an undesired effect to reload resources at runtime. This is very useful thing for fast iterative development.
sourcepub fn count_registered_resources(&self) -> usize
pub fn count_registered_resources(&self) -> usize
Returns total amount of registered resources.
sourcepub fn loading_progress(&self) -> usize
pub fn loading_progress(&self) -> usize
Returns percentage of loading progress. This method is useful to show progress on loading screen in your game. This method could be used alone if your game depends only on external resources, or if your game doing some heavy calculations this value can be combined with progress of your tasks.
sourcepub fn update(&mut self, dt: f32)
pub fn update(&mut self, dt: f32)
Update resource containers and do hot-reloading.
Resources are removed if they’re not used or reloaded if they have changed in disk.
Normally, this is called from Engine::update()
.
You should only call this manually if you don’t use that method.
sourcepub fn push(&mut self, resource: UntypedResource)
pub fn push(&mut self, resource: UntypedResource)
Adds a new resource in the container.
sourcepub fn find<P>(&self, path: P) -> Option<&UntypedResource>
pub fn find<P>(&self, path: P) -> Option<&UntypedResource>
sourcepub fn iter(&self) -> impl Iterator<Item = &UntypedResource>
pub fn iter(&self) -> impl Iterator<Item = &UntypedResource>
Creates an iterator over resources in the manager.
sourcepub fn destroy_unused_resources(&mut self)
pub fn destroy_unused_resources(&mut self)
Immediately destroys all resources in the manager that are not used anywhere else.
sourcepub fn count_pending_resources(&self) -> usize
pub fn count_pending_resources(&self) -> usize
Returns total amount of resources that still loading.
sourcepub fn count_loaded_resources(&self) -> usize
pub fn count_loaded_resources(&self) -> usize
Returns total amount of completely loaded resources.
sourcepub fn resources(&self) -> Vec<UntypedResource>
pub fn resources(&self) -> Vec<UntypedResource>
Returns a set of resource handled by this container.
sourcepub fn request<P>(&mut self, path: P) -> UntypedResource ⓘ
pub fn request<P>(&mut self, path: P) -> UntypedResource ⓘ
Tries to load a resources at a given path.
sourcepub fn reload_resource(&mut self, resource: UntypedResource)
pub fn reload_resource(&mut self, resource: UntypedResource)
Reloads a single resource.
sourcepub fn reload_resources(&mut self) -> Vec<UntypedResource>
pub fn reload_resources(&mut self) -> Vec<UntypedResource>
Reloads all resources in the container. Returns a list of resources that will be reloaded. You can use the list to wait until all resources are loading.
sourcepub fn get_wait_context(&self) -> ResourceWaitContext
pub fn get_wait_context(&self) -> ResourceWaitContext
Wait until all resources are loaded (or failed to load).
sourcepub fn try_reload_resource_from_path(&mut self, path: &Path) -> bool
pub fn try_reload_resource_from_path(&mut self, path: &Path) -> bool
Tries to reload a resource at the given path.
sourcepub fn unregister(&mut self, path: &Path)
pub fn unregister(&mut self, path: &Path)
Forgets that a resource at the given path was ever loaded, thus making it possible to reload it again as a new instance.
Auto Trait Implementations§
impl !Freeze for ResourceManagerState
impl !RefUnwindSafe for ResourceManagerState
impl Send for ResourceManagerState
impl !Sync for ResourceManagerState
impl Unpin for ResourceManagerState
impl !UnwindSafe for ResourceManagerState
Blanket Implementations§
source§impl<T> AsyncTaskResult for T
impl<T> AsyncTaskResult for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§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).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.