pub trait QPaladins: Main + Caching + Hooks + Validation + Addition {
    // Provided methods
    fn delete_file<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        coll: &'life1 Collection<Document>,
        model_name: &'life2 str,
        field_name: &'life3 str,
        file_default: Option<FileData>,
        image_default: Option<ImageData>
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
    fn db_get_file_info<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        coll: &'life1 Collection<Document>,
        field_name: &'life2 str
    ) -> Pin<Box<dyn Future<Output = Result<Value, Box<dyn Error>>> + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn calculate_thumbnail_size(
        width: f64,
        height: f64,
        max_size: f64
    ) -> (f64, f64) { ... }
    fn check<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        client: &'life1 Client,
        params: Option<(bool, bool)>
    ) -> Pin<Box<dyn Future<Output = Result<OutputData2, Box<dyn Error>>> + 'async_trait>>
       where Self: Serialize + DeserializeOwned + Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn save<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        client: &'life1 Client,
        options_insert: Option<InsertOneOptions>,
        options_update: Option<UpdateOptions>
    ) -> Pin<Box<dyn Future<Output = Result<OutputData2, Box<dyn Error>>> + 'async_trait>>
       where Self: Serialize + DeserializeOwned + Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn delete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        client: &'life1 Client,
        options: Option<DeleteOptions>
    ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>
       where Self: Serialize + DeserializeOwned + Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn create_password_hash(password: &str) -> Result<String, Box<dyn Error>> { ... }
    fn verify_password<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        client: &'life1 Client,
        password: &'life2 str,
        options: Option<FindOneOptions>
    ) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error>>> + 'async_trait>>
       where Self: Serialize + DeserializeOwned + Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn update_password<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        client: &'life1 Client,
        old_password: &'life2 str,
        new_password: &'life3 str,
        options_find_old: Option<FindOneOptions>,
        options_update: Option<UpdateOptions>
    ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>
       where Self: Serialize + DeserializeOwned + Sized + 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}

Provided Methods§

source

fn delete_file<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, coll: &'life1 Collection<Document>, model_name: &'life2 str, field_name: &'life3 str, file_default: Option<FileData>, image_default: Option<ImageData> ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Deleting a file in the database and in the file system.

source

fn db_get_file_info<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, coll: &'life1 Collection<Document>, field_name: &'life2 str ) -> Pin<Box<dyn Future<Output = Result<Value, Box<dyn Error>>> + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get file info from database.

source

fn calculate_thumbnail_size( width: f64, height: f64, max_size: f64 ) -> (f64, f64)

Calculate the maximum size for a thumbnail.

source

fn check<'life0, 'life1, 'async_trait>( &'life0 mut self, client: &'life1 Client, params: Option<(bool, bool)> ) -> Pin<Box<dyn Future<Output = Result<OutputData2, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Checking the Model before queries the database.

Example:
use chrono::Local;
let tz = Some(Local::now().format("%z").to_string()); // or None

let mut model_name = ModelName::new()?;
let output_data = model_name.check(&client, &tz, None).await?;
if !output_data.is_valid() {
    output_data.print_err();
}
source

fn save<'life0, 'life1, 'async_trait>( &'life0 mut self, client: &'life1 Client, options_insert: Option<InsertOneOptions>, options_update: Option<UpdateOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData2, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Save to database as a new document or update an existing document. Hint: Used in conjunction with the check() method.

Example:
use chrono::Local;
let tz = Some(Local::now().format("%z").to_string()); // or None

let mut model_name = ModelName::new()?;
let output_data = model_name.save(&client, &tz, None, None).await?;
if !output_data.is_valid() {
    output_data.print_err();
}
source

fn delete<'life0, 'life1, 'async_trait>( &'life0 self, client: &'life1 Client, options: Option<DeleteOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Remove document from collection.

Example:
let mut user = User{...};
let output_data = user.delete(&client, None).await?;
if !output_data.is_valid() {
    println!("{}", output_data.err_msg());
}
source

fn create_password_hash(password: &str) -> Result<String, Box<dyn Error>>

Generate password hash and add to result document.

Example:
let user = User::new().await?;
let password = user.password.get().unwrap();
println!("{}", user.create_password_hash(&password)?);
source

fn verify_password<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, client: &'life1 Client, password: &'life2 str, options: Option<FindOneOptions> ) -> Pin<Box<dyn Future<Output = Result<bool, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Match the password from the user to the password in the database.

Example:
let user = User {...};
let password = "12345678";
assert!(user.create_password_hash(&client, password, None).await?);
source

fn update_password<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, client: &'life1 Client, old_password: &'life2 str, new_password: &'life3 str, options_find_old: Option<FindOneOptions>, options_update: Option<UpdateOptions> ) -> Pin<Box<dyn Future<Output = Result<OutputData, Box<dyn Error>>> + 'async_trait>>where Self: Serialize + DeserializeOwned + Sized + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

For replace or recover password.

Example:
let user = User {...};
let old_password = "12345678";
// Valid characters: a-z A-Z 0-9 @ # $ % ^ & + = * ! ~ ) (
// Size: 8-256
let new_password = "UUbd+5KXw^756*uj";
let output_data = user.update_password(&client, old_password, new_password, None, None).await?;
if !output_data.is_valid()? {
    println!("{}", output_data.err_msg()?);
}

Implementors§