-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add more documentation examples * Args up through 6 * Fix readme example * Update doc badge
- Loading branch information
1 parent
7c2aa0b
commit 5cf8f7e
Showing
9 changed files
with
767 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "skedge" | ||
description = "Ergonomic single-process job scheduling for Rust programs." | ||
version = "0.0.6" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["Ben Lovy <[email protected]>"] | ||
documentation = "https://docs.rs/skedge" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// This is the exact code from the README.md example | ||
|
||
use chrono::Local; | ||
use skedge::{every, Scheduler}; | ||
use std::thread::sleep; | ||
use std::time::Duration; | ||
|
||
fn greet(name: &str) { | ||
println!("Hello {}, it's {}!", name, Local::now().to_rfc2822()); | ||
} | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let mut schedule = Scheduler::new(); | ||
|
||
every(2) | ||
.to(8)? | ||
.seconds()? | ||
.until(Local::now() + chrono::Duration::seconds(30))? | ||
.run_one_arg(&mut schedule, greet, "Good-Looking")?; | ||
|
||
println!("Starting at {}", Local::now()); | ||
loop { | ||
if let Err(e) = schedule.run_pending() { | ||
eprintln!("Error: {}", e); | ||
} | ||
sleep(Duration::from_secs(1)); | ||
} | ||
} |
Oops, something went wrong.