harmos_sidecar/kit/
identity.rs1use std::{fmt, io};
18#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
31pub struct ActivationId([u8; 16]);
32
33#[derive(Clone, Copy)]
34pub(super) struct Identity {
35 pub(super) observer: &'static str,
36 pub(super) activation: ActivationId,
37}
38
39impl Identity {
46 pub(super) fn new(observer: &'static str) -> io::Result<Self> {
47 let mut bytes = [0; 16];
48 getrandom::fill(&mut bytes)?;
49 Ok(Self {
50 observer,
51 activation: ActivationId(bytes),
52 })
53 }
54}
55
56impl fmt::Display for ActivationId {
57 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
58 for byte in self.0 {
59 write!(formatter, "{byte:02x}")?;
60 }
61 Ok(())
62 }
63}
64
65