Function gen

Source
pub fn gen(time: SystemTime) -> Result<String, Box<dyn Error>>
Expand description

Generate aid.

The aid consists of 8 bytes of milliseconds elapsed since 2000-01-01 00:00:00 UTC and 2 bytes of a random characters.

§Arguments

  • time - Indicates the current time. It will probably work if you put in a date in the past, but it’s probably best not to.

§Exmaple

use aid::gen;
use std::time::SystemTime;

let aid = gen(SystemTime::now());
Examples found in repository?
examples/gen_id.rs (line 7)
5fn main() {
6    for _ in 1..50 {
7        let aid = aid::gen(SystemTime::now()).unwrap();
8        println!("{}", aid);
9
10        sleep(Duration::from_millis(10));
11    }
12}