Struct Scheduler

Source
pub struct Scheduler<Tz = Local>
where Tz: TimeZone,
{ /* private fields */ }

Implementations§

Source§

impl Scheduler

Source

pub fn new() -> Scheduler

§Constructs a new scheduler

the default timezone is chrono::Local, if you want a specified timezone, use Scheduler::with_tz() instead.

§Example
let s = Scheduler::new();
Source

pub fn with_tz<Tz: TimeZone>(tz: Tz) -> Scheduler<Tz>

if you want a specified timezone instead of the mathine timezone chrono::Local, use this

Source§

impl<Tz> Scheduler<Tz>
where Tz: TimeZone + Clone + Sync + Send + Copy + 'static, <Tz as TimeZone>::Offset: Send + Sync,

Source

pub fn add_ext<T>(&self, ext: T)
where T: 'static + Send + Sync,

add a type to the map, you can use it later in the task closer

Source

pub fn add( &mut self, job: Box<dyn Job<Tz> + Send + 'static>, ) -> &mut Scheduler<Tz>

add a new task to the scheduler, you must privide something that implements Job trait.

Source

pub async fn run(&self) -> &Self

Start the timer.

Source

pub async fn run_pending(&self)

Start the timer, block the current thread.

Auto Trait Implementations§

§

impl<Tz> Freeze for Scheduler<Tz>
where Tz: Freeze,

§

impl<Tz = Local> !RefUnwindSafe for Scheduler<Tz>

§

impl<Tz> Send for Scheduler<Tz>
where Tz: Send,

§

impl<Tz = Local> !Sync for Scheduler<Tz>

§

impl<Tz> Unpin for Scheduler<Tz>
where Tz: Unpin,

§

impl<Tz = Local> !UnwindSafe for Scheduler<Tz>

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

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.