Trait UserSqlLogic

Source
pub trait UserSqlLogic {
    // Provided methods
    fn insert_user<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
        user: &'life1 User,
    ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_user<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
        username: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<User>, SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn update_user<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
        user: &'life1 User,
    ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn get_users<'life0, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<User>, SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait { ... }
    fn is_last_admin<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
        username: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool, SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn delete_user<'life0, 'life1, 'async_trait>(
        pool: &'life0 Pool<Postgres>,
        username: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait { ... }
}

Provided Methods§

Source

fn insert_user<'life0, 'life1, 'async_trait>( pool: &'life0 Pool<Postgres>, user: &'life1 User, ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Inserts a new user into the database.

§Arguments
  • pool - The database connection pool
  • user - The user to insert
§Returns
  • A result indicating success or failure
Source

fn get_user<'life0, 'life1, 'async_trait>( pool: &'life0 Pool<Postgres>, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<User>, SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Retrieves a user from the database by username.

§Arguments
  • pool - The database connection pool
  • username - The username of the user to retrieve
§Returns
  • A result containing the user if found, or None if not found
Source

fn update_user<'life0, 'life1, 'async_trait>( pool: &'life0 Pool<Postgres>, user: &'life1 User, ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Updates a user in the database.

§Arguments
  • pool - The database connection pool
  • user - The user to update
§Returns
  • A result indicating success or failure
Source

fn get_users<'life0, 'async_trait>( pool: &'life0 Pool<Postgres>, ) -> Pin<Box<dyn Future<Output = Result<Vec<User>, SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait,

Retrieves all users from the database.

§Arguments
  • pool - The database connection pool
§Returns
  • A result containing a vector of users
Source

fn is_last_admin<'life0, 'life1, 'async_trait>( pool: &'life0 Pool<Postgres>, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool, SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Checks if user is the last admin in the system.

§Arguments
  • pool - The database connection pool
  • username - The username of the user to check
§Returns
  • Boolean indicating if the user is the last admin
Source

fn delete_user<'life0, 'life1, 'async_trait>( pool: &'life0 Pool<Postgres>, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<(), SqlError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait,

Deletes a user from the database.

§Arguments
  • pool - The database connection pool
  • username - The username of the user to delete

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.

Implementors§