Struct prefixed_api_key::PrefixedApiKey
source · pub struct PrefixedApiKey { /* private fields */ }
Expand description
A struct representing the api token generated for, and provided to,
the user. An instance of this struct can be instantiated from a string
provided by the user for further validation, or it can be instantiated
via the new
method while generating a new key to be given to the user.
Implementations§
source§impl PrefixedApiKey
impl PrefixedApiKey
sourcepub fn new(
prefix: String,
short_token: String,
long_token: String
) -> PrefixedApiKey
pub fn new( prefix: String, short_token: String, long_token: String ) -> PrefixedApiKey
Constructs a new instance of the struct. This is just a wrapper around directly instantiating the struct, and makes no assertions or assumptions about the values provided.
sourcepub fn short_token(&self) -> &str
pub fn short_token(&self) -> &str
Getter method for accessing the keys short token
sourcepub fn long_token(&self) -> &str
pub fn long_token(&self) -> &str
Getter method for accessing the keys secret long token
sourcepub fn long_token_hashed<D: Digest + FixedOutputReset>(
&self,
digest: &mut D
) -> String
pub fn long_token_hashed<D: Digest + FixedOutputReset>( &self, digest: &mut D ) -> String
Gets the hashed form of the keys secret long token, using the hashing
algorithm provided as digest
. This resets the digest instance while
finalizing so it may be reused afterward.
sourcepub fn from_string(
pak_string: &str
) -> Result<PrefixedApiKey, PrefixedApiKeyError>
pub fn from_string( pak_string: &str ) -> Result<PrefixedApiKey, PrefixedApiKeyError>
Instantiates the struct from the string form of the api token. This
validates that the string has the expected number of parts (deliniated by "_"
),
but otherwise makes no assertions or assumptions about the values.
Trait Implementations§
source§impl Debug for PrefixedApiKey
impl Debug for PrefixedApiKey
A custom implementation of Debug that masks the secret long token that way the struct can be debug printed without leaking sensitive info into logs