1use std::{fmt, sync::Arc};
2
3#[derive(Clone, PartialEq, Eq)]
7pub struct HmacKey(Arc<[u8]>);
8
9impl HmacKey {
10 pub fn new(bytes: impl Into<Arc<[u8]>>) -> Self {
12 Self(bytes.into())
13 }
14
15 pub fn as_bytes(&self) -> &[u8] {
17 &self.0
18 }
19}
20
21impl fmt::Debug for HmacKey {
22 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
23 f.write_str("HmacKey([REDACTED])")
24 }
25}
26
27#[derive(Clone, Debug, Default, PartialEq, Eq)]
29pub enum Authentication {
30 #[default]
32 Unauthenticated,
33 Hmac(HmacKey),
35}
36
37impl Authentication {
38 pub(crate) fn hmac_key(&self) -> Option<&[u8]> {
39 match self {
40 Self::Unauthenticated => None,
41 Self::Hmac(key) => Some(key.as_bytes()),
42 }
43 }
44}