Struct tasklet::TaskBuilder

source ·
pub struct TaskBuilder<'a, T>
where T: TimeZone,
{ /* private fields */ }
Expand description

Task builder function.

Used to generate/build a TaskStep instance.

Implementations§

source§

impl<'a, T> TaskBuilder<'a, T>
where T: TimeZone,

source

pub fn new(timezone: T) -> TaskBuilder<'a, T>

Create a new TaskBuilder instance.

Arguments
  • timezone - A valid timezone for the generated Task.
Examples
let _task_builder = TaskBuilder::new(chrono::Utc);
source

pub fn description(self, description: &str) -> TaskBuilder<'a, T>

Set the optional description of the generated Task.

Arguments
  • description - A description for the task.
let _task = TaskBuilder::new(chrono::Local).every("* * * * * * *").description("Description").build();
source

pub fn every(self, expression: &str) -> TaskBuilder<'a, T>

Set the execution schedule of the task to be generated.

Arguments
  • expression - A valid cron expression.
Examples
let _task = TaskBuilder::new(chrono::Local).every("* * * * * * *").build();
source

pub fn repeat(self, repeat: usize) -> TaskBuilder<'a, T>

Set the max repeats for the generated Task.

Arguments
  • repeats - The max amount of repeats.
Examples
let _task = TaskBuilder::new(chrono::Local).repeat(5);
source

pub fn add_step<F>( self, description: Option<&str>, function: F ) -> TaskBuilder<'a, T>
where F: FnMut() -> Result<(), ()> + 'a,

Add a new step for the generated task.

Arguments
  • description - An optional description for the task’s step.
  • function - The executable body of the task’s step.
Examples
let _task = TaskBuilder::new(chrono::Local).add_step(None, || Ok(()));
let _task = TaskBuilder::new(chrono::Utc).add_step(Some("A step that fails."), || Err(()));
source

pub fn build(self) -> Task<'a, T>

Build a new Task instance from the current configuration.

Examples
let mut _task = TaskBuilder::new(chrono::Utc).build();

Auto Trait Implementations§

§

impl<'a, T> !RefUnwindSafe for TaskBuilder<'a, T>

§

impl<'a, T> !Send for TaskBuilder<'a, T>

§

impl<'a, T> !Sync for TaskBuilder<'a, T>

§

impl<'a, T> Unpin for TaskBuilder<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for TaskBuilder<'a, T>

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, 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>,

§

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>,

§

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.