feat: add Identifier::random and some other tiny fixes

This commit is contained in:
Strix 2023-10-15 18:06:25 +02:00
parent f462630eb4
commit 405cf8b368
No known key found for this signature in database
GPG key ID: 49B2E37B8915B774
8 changed files with 190 additions and 11 deletions

View file

@ -1,10 +1,17 @@
use std::fmt::{Display, Formatter, LowerHex};
use rand::random;
#[derive(Debug, Eq, PartialEq, Copy, Clone)]
pub struct Identifier {
pub bytes: [u8; 4],
}
impl Identifier {
pub fn random() -> Identifier {
Identifier::from(random::<u32>())
}
}
impl Display for Identifier {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(