helloasso-paheko-adapter/src/utils.rs

22 lines
414 B
Rust
Raw Normal View History

2023-12-21 16:31:21 +00:00
use serde::{Serialize, Deserialize};
use rand::{thread_rng, Rng};
/// ID
#[derive(Clone, Deserialize, Serialize, Debug, PartialEq, Eq, Hash)]
pub struct Id(pub u64);
impl Id {
pub fn to_string(&self) -> String {
format!("{:x}", self.0)
}
}
impl Into<String> for Id {
fn into(self) -> String {
format!("{:x}", self.0)
}
}
pub fn generate_id() -> Id {
Id(thread_rng().gen())
}