storage::store

Trait UserStore

Source
pub trait UserStore {
    // Required methods
    fn init_default_admin_user(
        &mut self,
        username: &str,
        password_hash: &str,
    ) -> Result<User, Error>;
    fn create_user(&mut self, user: &mut User) -> Result<(), Error>;
    fn delete_user(&mut self, id: Uuid) -> Result<(), Error>;
    fn update_user(&mut self, user: &mut User) -> Result<(), Error>;
    fn get_user(&self, id: Uuid) -> Result<User, Error>;
    fn find_user_by_name(&self, name: &str) -> Result<User, Error>;
    fn find_user_by_api_key(&self, api_key: Uuid) -> Result<User, Error>;
    fn get_users(&self) -> Result<Vec<User>, Error>;
}
Expand description

Represents a store for holding users

Required Methods§

Source

fn init_default_admin_user( &mut self, username: &str, password_hash: &str, ) -> Result<User, Error>

Adds the default admin user to the store if it doesn’t already exist, else returns it

Source

fn create_user(&mut self, user: &mut User) -> Result<(), Error>

Adds a new user to the store and sets the allocated id within the user object

Source

fn delete_user(&mut self, id: Uuid) -> Result<(), Error>

Deletes a user from the store

Source

fn update_user(&mut self, user: &mut User) -> Result<(), Error>

Updates a user within the store

Source

fn get_user(&self, id: Uuid) -> Result<User, Error>

Loads a user from the store

Source

fn find_user_by_name(&self, name: &str) -> Result<User, Error>

Locates a user by their username within the store

Source

fn find_user_by_api_key(&self, api_key: Uuid) -> Result<User, Error>

Locates a user by their api key within the store

Source

fn get_users(&self) -> Result<Vec<User>, Error>

Returns the list of users within the store, sorted alphabetically by username in ascending order

Implementors§