pub trait Task:
Sized
+ Send
+ Sync
+ 'static {
const TYPE: &'static str;
const VERSION: u32 = 1;
const ALIASES: &'static [&'static str] = _;
// Required methods
fn encode(&self) -> Result<Vec<u8>, CodecError>;
fn decode(bytes: &[u8]) -> Result<Self, CodecError>;
// Provided methods
fn upcast(version: u32, bytes: &[u8]) -> Result<Self, CodecError> { ... }
fn options() -> TaskOptions { ... }
}Expand description
A unit of work. TYPE is wire state — changing it strands enqueued jobs.
Required Associated Constants§
Provided Associated Constants§
Sourceconst VERSION: u32 = 1
const VERSION: u32 = 1
payload versioning Bump when the payload shape changes; implement upcast for the old one.
Sourceconst ALIASES: &'static [&'static str] = _
const ALIASES: &'static [&'static str] = _
typed dispatch Kinds this worker also answers to. Enqueue always uses TYPE; dispatch
matches TYPE or any alias. Without this, renaming a task strands every job of
the old kind — the same failure payload versioning prevents, through a door payload versioning does not cover.
Required Methods§
fn encode(&self) -> Result<Vec<u8>, CodecError>
fn decode(bytes: &[u8]) -> Result<Self, CodecError>
Provided Methods§
Sourcefn upcast(version: u32, bytes: &[u8]) -> Result<Self, CodecError>
fn upcast(version: u32, bytes: &[u8]) -> Result<Self, CodecError>
Decode an older payload into the current shape. The default rejects anything
but the current version, which sends the job to Undecodable rather than
retrying a decode error 25 times.
fn options() -> TaskOptions
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".