File: schedule.rs

package info (click to toggle)
rust-notify-rust 4.11.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 592 kB
  • sloc: sh: 18; makefile: 4
file content (29 lines) | stat: -rw-r--r-- 794 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#[cfg(target_os = "macos")]
fn main() -> Result<(), Box<dyn std::error::Error>> {
    use notify_rust::Notification;

    let duration = chrono::Duration::milliseconds(4321);
    let timestamp = (chrono::Utc::now() + duration).timestamp() as f64;

    Notification::new()
        .summary("Oh by the way")
        .body(&format!("this was scheduled {:?} ago", duration))
        .schedule(chrono::Utc::now() + duration)?;

    Notification::new()
        .summary("Oh by the way")
        .body(&format!("this was scheduled for timestamp {}", timestamp))
        .schedule_raw(timestamp)?;

    Ok(())
}

#[cfg(all(unix, not(target_os = "macos")))]
fn main() {
    println!("this is a mac only feature")
}

#[cfg(target_os = "windows")]
fn main() {
    println!("this is a mac only feature")
}