Crate planif

source ·
Expand description

A builder pattern wrapper around the windows-rs task scheduler API .

Provides an ergonomic builder for creating the following task types:

  • Boot
  • Daily
  • Event
  • Idle
  • Logon
  • Monthly
  • MonthlyDOW
  • Registration
  • Time
  • Weekly

Example

use chrono::prelude::*;
use planif::schedule::TaskCreationFlags;
use planif::schedule_builder::{Action, ScheduleBuilder};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let sb = ScheduleBuilder::new().unwrap();
    sb.create_daily()
        .author("planif")?
        .description("Daily Trigger")?
        .trigger("daily_trigger", true)?
        .days_interval(1)?
        .action(Action::new("test", "notepad.exe", "", ""))?
        .start_boundary(&Local::now().to_rfc3339())?
        .build()?
        .register("TaskName", TaskCreationFlags::CreateOrUpdate as i32)?;
    Ok(())
}

For more examples, refer to the planif/examples folder. The folder contains code for creating each of the triggers.

Modules