pub trait SecureToken {
// Required methods
fn secure_token_configurations() -> &'static [SecureTokenConfig];
fn get_secure_token(&self, field: &str) -> Option<&str>;
fn set_secure_token(&mut self, field: &str, token: String);
// Provided methods
fn generate_token() -> String { ... }
fn ensure_secure_tokens(
&mut self,
existing_tokens: &HashSet<String>,
) -> Result<(), SecureTokenError> { ... }
fn regenerate_token(
&mut self,
field: &str,
existing_tokens: &HashSet<String>,
) -> Result<String, SecureTokenError> { ... }
}Expand description
Trait implemented by records that expose secure-token fields.
Required Methods§
Sourcefn secure_token_configurations() -> &'static [SecureTokenConfig]
fn secure_token_configurations() -> &'static [SecureTokenConfig]
Returns secure-token metadata for the record type.
Sourcefn get_secure_token(&self, field: &str) -> Option<&str>
fn get_secure_token(&self, field: &str) -> Option<&str>
Reads the current token value for field.
Sourcefn set_secure_token(&mut self, field: &str, token: String)
fn set_secure_token(&mut self, field: &str, token: String)
Stores a token value for field.
Provided Methods§
Sourcefn generate_token() -> String
fn generate_token() -> String
Generates a cryptographically random token string.
Sourcefn ensure_secure_tokens(
&mut self,
existing_tokens: &HashSet<String>,
) -> Result<(), SecureTokenError>
fn ensure_secure_tokens( &mut self, existing_tokens: &HashSet<String>, ) -> Result<(), SecureTokenError>
Ensures every declared secure-token field has a unique value.
Sourcefn regenerate_token(
&mut self,
field: &str,
existing_tokens: &HashSet<String>,
) -> Result<String, SecureTokenError>
fn regenerate_token( &mut self, field: &str, existing_tokens: &HashSet<String>, ) -> Result<String, SecureTokenError>
Replaces the token stored in field and returns the new value.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.