ResultMessage

Struct ResultMessage 

Source
pub struct ResultMessage {
Show 14 fields pub task_id: Uuid, pub status: TaskStatus, pub result: Option<Value>, pub traceback: Option<String>, pub exception: Option<ExceptionInfo>, pub date_done: Option<DateTime<Utc>>, pub task: Option<String>, pub worker: Option<String>, pub retries: Option<u32>, pub parent_id: Option<Uuid>, pub root_id: Option<Uuid>, pub group_id: Option<Uuid>, pub children: Vec<Uuid>, pub meta: HashMap<String, Value>,
}
Expand description

Task result message (Celery-compatible format)

Fields§

§task_id: Uuid

Task ID

§status: TaskStatus

Task status

§result: Option<Value>

Result value (for SUCCESS)

§traceback: Option<String>

Traceback (for FAILURE)

§exception: Option<ExceptionInfo>

Exception info (for FAILURE)

§date_done: Option<DateTime<Utc>>

Timestamp when result was created

§task: Option<String>

Task name

§worker: Option<String>

Worker that executed the task

§retries: Option<u32>

Retry count

§parent_id: Option<Uuid>

Parent task ID (for workflows)

§root_id: Option<Uuid>

Root task ID (for workflows)

§group_id: Option<Uuid>

Group ID (for grouped tasks)

§children: Vec<Uuid>

Children task IDs

§meta: HashMap<String, Value>

Additional metadata

Implementations§

Source§

impl ResultMessage

Source

pub fn new(task_id: Uuid, status: TaskStatus) -> Self

Create a new result message

Source

pub fn pending(task_id: Uuid) -> Self

Create a pending result

Source

pub fn success(task_id: Uuid, result: Value) -> Self

Create a successful result

Source

pub fn failure(task_id: Uuid, exc_type: &str, exc_message: &str) -> Self

Create a failure result

Source

pub fn failure_with_traceback( task_id: Uuid, exc_type: &str, exc_message: &str, traceback: &str, ) -> Self

Create a failure result with traceback

Source

pub fn retry(task_id: Uuid, retries: u32) -> Self

Create a retry result

Source

pub fn revoked(task_id: Uuid) -> Self

Create a revoked result

Source

pub fn started(task_id: Uuid) -> Self

Create a started result

Source

pub fn received(task_id: Uuid) -> Self

Create a received result

Source

pub fn with_task(self, task: impl Into<String>) -> Self

Set the task name

Source

pub fn with_worker(self, worker: impl Into<String>) -> Self

Set the worker name

Source

pub fn with_parent(self, parent_id: Uuid) -> Self

Set the parent task ID

Source

pub fn with_root(self, root_id: Uuid) -> Self

Set the root task ID

Source

pub fn with_group(self, group_id: Uuid) -> Self

Set the group ID

Source

pub fn with_child(self, child_id: Uuid) -> Self

Add a child task ID

Source

pub fn with_children(self, children: Vec<Uuid>) -> Self

Set children task IDs

Source

pub fn with_meta(self, key: impl Into<String>, value: Value) -> Self

Add metadata

Source

pub fn with_retries(self, retries: u32) -> Self

Set retry count

Source

pub fn with_date_done(self, date_done: DateTime<Utc>) -> Self

Set completion timestamp

Source

pub fn add_meta(&mut self, key: impl Into<String>, value: Value)

Add a single metadata entry (mutable)

Source

pub fn get_meta(&self, key: &str) -> Option<&Value>

Get a metadata value by key

Source

pub fn has_meta(&self, key: &str) -> bool

Check if metadata key exists

Source

pub fn meta_len(&self) -> usize

Get the number of metadata entries

Source

pub fn retry_count(&self) -> u32

Get the retry count (defaults to 0 if not set)

Source

pub fn is_ready(&self) -> bool

Check if the result is ready

Source

pub fn is_success(&self) -> bool

Check if the task succeeded

Source

pub fn is_failure(&self) -> bool

Check if the task failed

Source

pub fn get_result(&self) -> Option<&Value>

Get the result value (if success)

Source

pub fn get_exception(&self) -> Option<&ExceptionInfo>

Get the exception info (if failure)

Source

pub fn to_json(&self) -> Result<Vec<u8>, Error>

Serialize to JSON bytes

Source

pub fn from_json(bytes: &[u8]) -> Result<Self, Error>

Deserialize from JSON bytes

Trait Implementations§

Source§

impl Clone for ResultMessage

Source§

fn clone(&self) -> ResultMessage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ResultMessage

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ResultMessage

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ResultMessage

Source§

fn eq(&self, other: &ResultMessage) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ResultMessage

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ResultMessage

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,