sylvia_iot_auth::models::user

Trait UserModel

Source
pub trait UserModel: Sync {
    // Required methods
    fn init<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn count<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cond: &'life1 ListQueryCond<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn list<'life0, 'life1, 'async_trait>(
        &'life0 self,
        opts: &'life1 ListOptions<'_>,
        cursor: Option<Box<dyn Cursor>>,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<User>, Option<Box<dyn Cursor>>), Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cond: &'life1 QueryCond<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<Option<User>, Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn add<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user: &'life1 User,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn del<'life0, 'life1, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        user_id: &'life1 str,
        updates: &'life2 Updates<'_>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Model operations.

Required Methods§

Source

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

To create and initialize the table/collection.

Source

fn count<'life0, 'life1, 'async_trait>( &'life0 self, cond: &'life1 ListQueryCond<'_>, ) -> Pin<Box<dyn Future<Output = Result<u64, Box<dyn StdError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

To get item count for the query condition.

Note: this may take a long time.

Source

fn list<'life0, 'life1, 'async_trait>( &'life0 self, opts: &'life1 ListOptions<'_>, cursor: Option<Box<dyn Cursor>>, ) -> Pin<Box<dyn Future<Output = Result<(Vec<User>, Option<Box<dyn Cursor>>), Box<dyn StdError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

To get item list. The maximum number of returned items will be controlled by the cursor_max of the list option.

For the first time, cursor MUST use None. If one cursor is returned, it means that there are more items to get. Use the returned cursor to get more data items.

Note: using cursors is recommended to prevent exhausting memory.

Source

fn get<'life0, 'life1, 'async_trait>( &'life0 self, cond: &'life1 QueryCond<'_>, ) -> Pin<Box<dyn Future<Output = Result<Option<User>, Box<dyn StdError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

To get an item.

Source

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

To add an item.

Source

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

To delete one or more items.

Source

fn update<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user_id: &'life1 str, updates: &'life2 Updates<'_>, ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn StdError>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

To update one or more items.

Implementors§