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
/*
    Appellation: alphabet <module>
    Creator: FL03 <jo3mccain@icloud.com>
    Description:
        ... Summary ...
*/
#[derive(Clone, Debug, Hash, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct StringGenerator {
    pub data: String,
    pub timestamp: i64,
}

impl StringGenerator {
    fn constructor(data: String, timestamp: i64) -> Self {
        Self { data, timestamp }
    }
    pub fn new(data: String) -> Self {
        Self::constructor(data, crate::Temporal::now().timestamp())
    }
    pub fn generate(len: usize) -> crate::BoxResult<Self> {
        Ok(Self::new(crate::generate::generate_random_string(len)))
    }
}

impl Default for StringGenerator {
    fn default() -> Self {
        Self::generate(12).ok().unwrap()
    }
}