pub struct TaskDefinition<T = ()> {
    pub target: UnixNanos,
    pub worker_selector: WorkerSelector,
    pub data: Vec<u8>,
    pub data_format: TaskDataFormat,
    pub labels: HashMap<String, Value>,
    pub timeout: TimeoutPolicy,
    /* private fields */
}
Expand description

An untyped complete task definition that can be added to the queue.

Fields§

§target: UnixNanos

The target time of the task execution.

§worker_selector: WorkerSelector

The worker selector of the task.

§data: Vec<u8>

Arbitrary task data that is passed to the workers.

§data_format: TaskDataFormat

The input data format.

§labels: HashMap<String, Value>

Arbitrary task labels.

§timeout: TimeoutPolicy

An optional timeout policy.

Implementations§

source§

impl<T> TaskDefinition<T>

source

pub fn with_timeout(self, timeout: impl Into<TimeoutPolicy>) -> Self

Set a timeout policy.

source

pub fn immediate(self) -> Self

Schedule the task immediately.

source

pub fn at(self, target: OffsetDateTime) -> Self

Set the target execution time of the new task.

source

pub fn at_unix(self, target: UnixNanos) -> Self

Schedule the task at the given unix nanosecond duration.

source

pub fn now(self) -> Self

Schedule the task with the current time as target.

source

pub fn after(self, duration: Duration) -> Self

Set the target execution time of the new task to be after the given duration.

Panics

Panics if the system time is before UNIX epoch.

source

pub fn with_worker_selector(self, selector: impl Into<WorkerSelector>) -> Self

Set the worker selector for the given task.

source

pub fn with_label(self, name: &str, value: impl Serialize) -> Self

Set a label value.

Panics

Panics if the value is not JSON-serializable.

source

pub fn cast<U>(self) -> TaskDefinition<U>

Cast the task to a different task type, or to erase the task type replacing it with ().

This is not required in most circumstances.

Trait Implementations§

source§

impl<T> Clone for TaskDefinition<T>

source§

fn clone(&self) -> Self

Returns a copy 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<T: Debug> Debug for TaskDefinition<T>

source§

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

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

impl<'de, T> Deserialize<'de> for TaskDefinition<T>

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<T> Serialize for TaskDefinition<T>

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

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for TaskDefinition<T>where T: RefUnwindSafe,

§

impl<T> Send for TaskDefinition<T>where T: Send,

§

impl<T> Sync for TaskDefinition<T>where T: Sync,

§

impl<T> Unpin for TaskDefinition<T>where T: Unpin,

§

impl<T> UnwindSafe for TaskDefinition<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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 Twhere T: for<'de> Deserialize<'de>,