pub trait AsyncJob:
Send
+ Sync
+ Clone {
type Notification: Copy + Send;
type Progress: Clone + Default + Send + Sync + PartialEq;
// Required method
fn run(
&mut self,
params: RunParams<Self::Notification, Self::Progress>,
) -> Result<Self::Notification>;
// Provided method
fn get_progress(&self) -> Self::Progress { ... }
}
Expand description
trait that defines an async task we can run on a threadpool
Required Associated Types§
Sourcetype Notification: Copy + Send
type Notification: Copy + Send
defines what notification type is used to communicate outside
Required Methods§
Sourcefn run(
&mut self,
params: RunParams<Self::Notification, Self::Progress>,
) -> Result<Self::Notification>
fn run( &mut self, params: RunParams<Self::Notification, Self::Progress>, ) -> Result<Self::Notification>
can run a synchronous time intensive task.
the returned notification is used to tell interested parties
that the job finished and the job can be access via
take_last
. prior to this final notification it is not safe
to assume take_last
will already return the correct job
Provided Methods§
Sourcefn get_progress(&self) -> Self::Progress
fn get_progress(&self) -> Self::Progress
allows observers to get intermediate progress status if the
job customizes it by default this will be returning
Self::Progress::default()
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.