[][src]Trait splinter::biome::credentials::store::CredentialsStore

pub trait CredentialsStore: Send + Sync {
    fn add_credentials(
        &self,
        credentials: Credentials
    ) -> Result<(), CredentialsStoreError>;
fn update_credentials(
        &self,
        user_id: &str,
        updated_username: &str,
        updated_password: &str
    ) -> Result<(), CredentialsStoreError>;
fn remove_credentials(
        &self,
        user_id: &str
    ) -> Result<(), CredentialsStoreError>;
fn fetch_credential_by_user_id(
        &self,
        user_id: &str
    ) -> Result<Credentials, CredentialsStoreError>;
fn fetch_credential_by_username(
        &self,
        username: &str
    ) -> Result<Credentials, CredentialsStoreError>;
fn fetch_username_by_id(
        &self,
        user_id: &str
    ) -> Result<UsernameId, CredentialsStoreError>;
fn list_usernames(&self) -> Result<Vec<UsernameId>, CredentialsStoreError>; }

Defines methods for CRUD operations and fetching a user’s credentials without defining a storage strategy

Required methods

fn add_credentials(
    &self,
    credentials: Credentials
) -> Result<(), CredentialsStoreError>

Adds a credential to the underlying storage

Arguments

  • credentials - Credentials to be added

Errors

Returns a CredentialsStoreError if the implementation cannot add a new credential

fn update_credentials(
    &self,
    user_id: &str,
    updated_username: &str,
    updated_password: &str
) -> Result<(), CredentialsStoreError>

Replaces a credential for a user in the underlying storage with new credentials. This assumes that the user has only one credential in storage

Arguments

  • user_id - The unique identifier of the user the credential belongs to
  • updated_username - The updated username for the user
  • updated_password - The updated password for the user

Errors

Returns a CredentialsStoreError if the implementation cannot update credentials or if the specified credentials do not exist

fn remove_credentials(&self, user_id: &str) -> Result<(), CredentialsStoreError>

Removes a credential from a user from the underlying storage

Arguments

  • user_id - The unique identifier of the user the credential belongs to

Errors

Returns a CredentialsStoreError if implementation cannot delete the credential

fn fetch_credential_by_user_id(
    &self,
    user_id: &str
) -> Result<Credentials, CredentialsStoreError>

Fetches a credential for a user

Arguments

  • user_id - The unique identifier of the user the credential belongs to

Errors

Returns a CredentialsStoreError if implementation cannot fetch the credential or if the credential cannot be found

fn fetch_credential_by_username(
    &self,
    username: &str
) -> Result<Credentials, CredentialsStoreError>

Fetches a credential for a user

Arguments

  • username - The username the user uses for login

Errors

Returns a CredentialsStoreError if implementation cannot fetch the credential or if the credential cannot be found

fn fetch_username_by_id(
    &self,
    user_id: &str
) -> Result<UsernameId, CredentialsStoreError>

Fetches the username for a user by user_id

Arguments

  • user_id - The unique identifier of the user the credential belongs to

Errors

Returns a CredentialsStoreError if implementation cannot fetch the user ID or if the user ID cannot be found

fn list_usernames(&self) -> Result<Vec<UsernameId>, CredentialsStoreError>

Fetches user names

Errors

Returns a CredentialsStoreError if implementation cannot fetch the user IDs

Loading content...

Implementors

impl CredentialsStore for DieselCredentialsStore[src]

impl CredentialsStore for MemoryCredentialsStore[src]

Loading content...