summaryrefslogtreecommitdiff
path: root/src/token/secret.rs
blob: 28c93bbe912bbd9e19dc8cd4edd614c0def0bf3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::fmt;

#[derive(sqlx::Type)]
#[sqlx(transparent)]
pub struct Secret(String);

impl Secret {
    pub fn reveal(self) -> String {
        let Self(secret) = self;
        secret
    }
}

impl fmt::Debug for Secret {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.debug_tuple("IdentityToken").field(&"********").finish()
    }
}

impl<S> From<S> for Secret
where
    S: Into<String>,
{
    fn from(value: S) -> Self {
        Self(value.into())
    }
}