Skip to main content

UserRepository

Trait UserRepository 

Source
pub trait UserRepository<U: AuthenticatableUser = SimpleUser>: Send + Sync {
    // Required methods
    fn find_by_email<'life0, 'life1, 'async_trait>(
        &'life0 self,
        email: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn find_by_id<'life0, 'life1, 'async_trait>(
        &'life0 self,
        id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn create<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user: &'life1 U,
    ) -> Pin<Box<dyn Future<Output = Result<U>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user: &'life1 U,
    ) -> Pin<Box<dyn Future<Output = Result<U>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_last_login<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn increment_failed_attempts<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn reset_failed_attempts<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn lock_account<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 Uuid,
        locked_until: Option<DateTime<Utc>>,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn unlock_account<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn exists_by_email<'life0, 'life1, 'async_trait>(
        &'life0 self,
        email: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Generic user repository trait for database operations

The generic type U must implement AuthenticatableUser.

Required Methods§

Source

fn find_by_email<'life0, 'life1, 'async_trait>( &'life0 self, email: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find user by email address

Source

fn find_by_id<'life0, 'life1, 'async_trait>( &'life0 self, id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<U>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Find user by ID

Source

fn create<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 U, ) -> Pin<Box<dyn Future<Output = Result<U>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create new user

Source

fn update<'life0, 'life1, 'async_trait>( &'life0 self, user: &'life1 U, ) -> Pin<Box<dyn Future<Output = Result<U>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update user

Source

fn update_last_login<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Update user’s last login timestamp

Source

fn increment_failed_attempts<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Increment failed login attempts

Source

fn reset_failed_attempts<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Reset failed login attempts

Source

fn lock_account<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 Uuid, locked_until: Option<DateTime<Utc>>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lock user account

Source

fn unlock_account<'life0, 'life1, 'async_trait>( &'life0 self, user_id: &'life1 Uuid, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unlock user account

Source

fn exists_by_email<'life0, 'life1, 'async_trait>( &'life0 self, email: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Check if user exists by email

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§