relaygate_protocol/
secret.rs1pub const MAX_BEARER_TOKEN_BYTES: usize = 4096;
3
4#[derive(Clone, PartialEq, Eq)]
6pub struct BearerToken(String);
7
8impl BearerToken {
9 pub fn new(value: impl Into<String>) -> Result<Self, crate::ProtocolError> {
14 let value = value.into();
15 if value.len() > MAX_BEARER_TOKEN_BYTES {
16 return Err(crate::ProtocolError::FieldTooLong {
17 field: "access_token",
18 actual: value.len(),
19 maximum: MAX_BEARER_TOKEN_BYTES,
20 });
21 }
22 Ok(Self(value))
23 }
24
25 #[must_use]
29 pub fn expose_secret(&self) -> &str {
30 &self.0
31 }
32}
33
34impl std::fmt::Debug for BearerToken {
35 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
36 formatter.write_str("BearerToken([REDACTED])")
37 }
38}