pub trait Job:
Serialize
+ DeserializeOwned
+ Send
+ Sync
+ 'static {
const JOB_TYPE: &'static str;
// Required method
fn handle(&self) -> impl Future<Output = Result<(), AppError>> + Send;
}Expand description
A unit of deferred work. Implemented once per job type, the same
“app implements this once per thing” shape as Policy<U>/Mailable.
Required Associated Constants§
Required Methods§
Sourcefn handle(&self) -> impl Future<Output = Result<(), AppError>> + Send
fn handle(&self) -> impl Future<Output = Result<(), AppError>> + Send
-> impl Future<...> + Send rather than a plain async fn - the
exact spelling larust_auth::Authenticatable::find_for_auth
already established (see docs/GOTCHAS.md) to avoid the
async-fn-in-traits Send-propagation pitfall. Unlike Mailable’s
methods, a job’s handle() is inherently real async I/O (sending
mail, calling an API, writing to the DB), so - unlike Mailable -
there’s no sidestepping this by staying synchronous.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".