pub struct CronScheduler { /* private fields */ }Expand description
Session-scoped prompt scheduler.
Create with CronScheduler::new, then call CronScheduler::start to
launch the background ticker.
Implementations§
Source§impl CronScheduler
impl CronScheduler
Sourcepub fn new() -> (Arc<Self>, UnboundedReceiver<ScheduledFire>)
pub fn new() -> (Arc<Self>, UnboundedReceiver<ScheduledFire>)
Create a new scheduler and its receiver channel.
Call CronScheduler::start after wrapping in Arc to start the ticker.
Sourcepub fn start(scheduler: Arc<Self>)
pub fn start(scheduler: Arc<Self>)
Spawn the background 1-second ticker.
The task holds a Weak reference so it exits automatically when the
Arc<CronScheduler> is dropped (i.e., when the session is dropped).
Sourcepub fn create_task(
&self,
prompt: String,
interval: Duration,
recurring: bool,
) -> Result<String, String>
pub fn create_task( &self, prompt: String, interval: Duration, recurring: bool, ) -> Result<String, String>
Schedule a new task. Returns the task ID on success.
Sourcepub fn list_tasks(&self) -> Vec<ScheduledTaskInfo>
pub fn list_tasks(&self) -> Vec<ScheduledTaskInfo>
List all active tasks sorted by ID.
Sourcepub fn cancel_task(&self, id: &str) -> bool
pub fn cancel_task(&self, id: &str) -> bool
Cancel a task by ID. Returns true if it existed.
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Number of active tasks.
Auto Trait Implementations§
impl !Freeze for CronScheduler
impl RefUnwindSafe for CronScheduler
impl Send for CronScheduler
impl Sync for CronScheduler
impl Unpin for CronScheduler
impl UnsafeUnpin for CronScheduler
impl UnwindSafe for CronScheduler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more