Have you considered representing tasks by structs of their context instead of functions? This way we could avoid explicit context deserialization and related bugs. E.g. this would be impossible:
struct Foo;
struct Bar;
#[job]
pub async fn foo(job: CurrentJob) -> Result<..> {
let context: Foo = job.json()?;
}
foo.builder().set_json(&Bar).spawn(&db).await?;
It would be something like:
#[derive(Job)]
struct MyJob;
impl CurrentJob for MyJob {
fn run(self) -> Result<..> {
}
}
MyJob { ... }.spawn(&db).await?;
Have you considered representing tasks by structs of their context instead of functions? This way we could avoid explicit context deserialization and related bugs. E.g. this would be impossible:
It would be something like: