twoken 0.4.0

Generate One-Time Passwords from stored token secrets.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::{thread::sleep, time::Duration};

use anyhow::{anyhow, Result};
use cli_clipboard::{ClipboardContext, ClipboardProvider};

pub fn set_and_clear_clipboard(text: &str, timeout: f32) -> Result<()> {
    let mut ctx = ClipboardContext::new().map_err(|e| anyhow!("{}", e))?;
    ctx.set_contents(text.to_owned())
        .map_err(|e| anyhow!("{}", e))?;
    sleep(Duration::from_secs_f32(timeout));
    Ok(())
}