[−][src]Struct paddle::LoadScheduler
Helper object to manage resource loading.
Usage
1. Register a set of futures that will load the resources 2. Call `attach_to_domain`, which will consume the `LoadScheduler` 3. (optional) Subscribe to `LoadingProgress` event 4. Subscribe to `LoadingDone` event and extract resources from the `LoadedData` object in the domain
Nuts Events published
LoadingProgress: Published on every resource that has been loaded, including the relative progress and the message of a currently loaded resource
LoadingDone: Published once when the last resource finished loading
Implementations
impl LoadScheduler
[src]
pub fn new() -> Self
[src]
pub fn attach_to_domain(self)
[src]
pub fn register<T: Sized + 'static, F: Future<Output = T> + 'static>(
&mut self,
future: F,
msg: &'static str
)
[src]
&mut self,
future: F,
msg: &'static str
)
Register a future to be loaded.
The future will be spawned and automatically reporting to the load scheduler is set up for afterwards.
pub fn register_vec<T: Sized + 'static, F: Future<Output = T> + 'static>(
&mut self,
future_vec: Vec<F>,
msg: &'static str
)
[src]
&mut self,
future_vec: Vec<F>,
msg: &'static str
)
Same as register
but for a vector of futures.
The LoadedData
will contain a vector with the values loaded in the exact same order.
pub fn register_manually_reported<T: Any>(&mut self, msg: &'static str)
[src]
Register a data type that needs to be loaded.
When this function is used, the data has to be manually added using add_progress
.
It can then be later extracted from LoadedData just like data registers as futures.
This is useful when some of data to load does not use a future.
pub fn with<T: Any, F: Future<Output = T> + 'static>(
self,
future: F,
msg: &'static str
) -> Self
[src]
self,
future: F,
msg: &'static str
) -> Self
Builder pattern for register
pub fn with_vec<T: Any, F: Future<Output = T> + 'static>(
self,
futures: Vec<F>,
msg: &'static str
) -> Self
[src]
self,
futures: Vec<F>,
msg: &'static str
) -> Self
Builder pattern for register_vec
pub fn with_manually_reported<T: Any>(self, msg: &'static str) -> Self
[src]
Builder pattern for register_manually_reported
pub fn add_progress_boxed(&mut self, loaded: Box<dyn Any>)
[src]
Update the progress tracking with a new resource
pub fn add_progress<T: Any>(&mut self, loaded: T)
[src]
Update the progress tracking with a new resource. The resource will be put in a box, so if you already have one, just use add_progress_boxed to avoid an extra reboxing.
pub fn add_vec_progress(&mut self, loaded: Box<dyn Any>, index: usize)
[src]
Update the progress tracking with a new resource
pub fn progress(&self) -> f32
[src]
Reports relative loading progress between 0.0 and 1.0
pub fn done(&self) -> bool
[src]
Returns true iff all registered resources are fully loaded.
pub fn waiting_for(&self) -> Option<&'static str>
[src]
If there are resources left to be loaded, returns the loading message of one of them.
pub fn finish(&mut self) -> LoadedData
[src]
Trait Implementations
impl Default for LoadScheduler
[src]
pub fn default() -> LoadScheduler
[src]
Auto Trait Implementations
impl !RefUnwindSafe for LoadScheduler
[src]
impl !Send for LoadScheduler
[src]
impl !Sync for LoadScheduler
[src]
impl Unpin for LoadScheduler
[src]
impl !UnwindSafe for LoadScheduler
[src]
Blanket Implementations
impl<T> Activity for T where
T: Any,
[src]
T: Any,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,