TaskBuilder

Struct TaskBuilder 

Source
pub struct TaskBuilder<Args, Ctx, IdType> { /* private fields */ }
Expand description

Builder for creating Task instances with optional configuration

Implementations§

Source§

impl<Args, Ctx, IdType> TaskBuilder<Args, Ctx, IdType>

Source

pub fn new(args: Args) -> Self
where Ctx: Default,

Create a new TaskBuilder with the required args

Source

pub fn with_ctx(self, ctx: Ctx) -> Self

Set the task’s backend context

Source

pub fn with_data(self, data: Extensions) -> Self

Set the task’s runtime data

Source

pub fn data<D: Clone + Send + Sync + 'static>(self, value: D) -> Self

Insert a value into the task’s data context

Source

pub fn meta<M>(self, value: M) -> Self
where Ctx: MetadataExt<M>,

Insert a value into the task’s ctx context

Source

pub fn with_task_id(self, task_id: TaskId<IdType>) -> Self

Set the task ID

Source

pub fn with_attempt(self, attempt: Attempt) -> Self

Set the attempt information

Source

pub fn with_status(self, status: Status) -> Self

Set the task status

Source

pub fn run_at_timestamp(self, timestamp: u64) -> Self

Schedule the task to run at a specific Unix timestamp

Source

pub fn run_at_time(self, time: SystemTime) -> Self

Schedule the task to run at a specific SystemTime

Source

pub fn run_after(self, delay: Duration) -> Self

Schedule the task to run after a delay from now

Source

pub fn run_in_seconds(self, seconds: u64) -> Self

Schedule the task to run in the specified number of seconds

Source

pub fn run_in_minutes(self, minutes: u64) -> Self

Schedule the task to run in the specified number of minutes

Source

pub fn run_in_hours(self, hours: u64) -> Self

Schedule the task to run in the specified number of hours

Source

pub fn build(self) -> Task<Args, Ctx, IdType>

Build the Task with default context

Trait Implementations§

Source§

impl<Args: Debug, Ctx: Debug, IdType: Debug> Debug for TaskBuilder<Args, Ctx, IdType>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Args, Ctx, IdType> Freeze for TaskBuilder<Args, Ctx, IdType>
where Args: Freeze, Ctx: Freeze, IdType: Freeze,

§

impl<Args, Ctx, IdType> !RefUnwindSafe for TaskBuilder<Args, Ctx, IdType>

§

impl<Args, Ctx, IdType> Send for TaskBuilder<Args, Ctx, IdType>
where Args: Send, Ctx: Send, IdType: Send,

§

impl<Args, Ctx, IdType> Sync for TaskBuilder<Args, Ctx, IdType>
where Args: Sync, Ctx: Sync, IdType: Sync,

§

impl<Args, Ctx, IdType> Unpin for TaskBuilder<Args, Ctx, IdType>
where Args: Unpin, Ctx: Unpin, IdType: Unpin,

§

impl<Args, Ctx, IdType> !UnwindSafe for TaskBuilder<Args, Ctx, IdType>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more