pub struct TaskContext {
pub task_id: TaskId,
pub instance_id: InstanceId,
pub scheduled_at: DateTime<Utc>,
pub attempt: u32,
/* private fields */
}Expand description
Execution context passed to task handlers.
Fields§
§task_id: TaskIdTask ID.
instance_id: InstanceIdInstance ID.
scheduled_at: DateTime<Utc>Scheduled execution time.
attempt: u32Current attempt number.
Implementations§
Source§impl TaskContext
impl TaskContext
Sourcepub fn new(
task_id: TaskId,
instance_id: InstanceId,
scheduled_at: DateTime<Utc>,
attempt: u32,
payload: Bytes,
) -> Self
pub fn new( task_id: TaskId, instance_id: InstanceId, scheduled_at: DateTime<Utc>, attempt: u32, payload: Bytes, ) -> Self
Create a new task context.
Sourcepub fn payload_bytes(&self) -> &Bytes
pub fn payload_bytes(&self) -> &Bytes
Get the raw payload bytes.
Sourcepub fn payload<T: DeserializeOwned>(&self) -> Result<T, Error>
pub fn payload<T: DeserializeOwned>(&self) -> Result<T, Error>
Deserialize the payload.
Trait Implementations§
Source§impl Clone for TaskContext
impl Clone for TaskContext
Source§fn clone(&self) -> TaskContext
fn clone(&self) -> TaskContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for TaskContext
impl RefUnwindSafe for TaskContext
impl Send for TaskContext
impl Sync for TaskContext
impl Unpin for TaskContext
impl UnwindSafe for TaskContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more