# Struct Database

Source

    pub struct Database {
        pub pool: MySqlPool,
    }

## Fields§

§`pool: MySqlPool`

## Trait Implementations§

Source§

### impl Clone for Database

Source§

#### fn clone(&self) -> Database

Returns a duplicate of the value. Read more
1.0.0 · Source§

#### fn clone_from(&mut self, source: &Self)

Performs copy-assignment from `source`. Read more
Source§

### impl MCDatabase for Database

Source§

#### fn ping<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

ping DB

Source§

#### fn register<'life0, 'life1, 'async_trait>( &'life0 self, p: &'life1 Register<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

register a new user

Source§

#### fn delete_user<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

delete a user

Source§

#### fn username_exists<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

check if username exists

Source§

#### fn get_email<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<Option<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get user email

Source§

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

check if email exists

Source§

#### fn update_email<'life0, 'life1, 'async_trait>( &'life0 self, p: &'life1 UpdateEmail<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

update a user’s email

Source§

#### fn get_password<'life0, 'life1, 'async_trait>( &'life0 self, l: &'life1 Login<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<NameHash>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get a user’s password

Source§

#### fn update_password<'life0, 'life1, 'async_trait>( &'life0 self, p: &'life1 NameHash, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

update user’s password

Source§

#### fn update_username<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, current: &'life1 str, new: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

update username

Source§

#### fn get_secret<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<Secret>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get a user’s secret

Source§

#### fn get_secret_from_captcha<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<Secret>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get a user’s secret from a captcha key

Source§

#### fn update_secret<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, secret: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

update a user’s secret

Source§

#### fn create_captcha<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, p: &'life2 CreateCaptcha<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

create new captcha

Source§

#### fn get_captcha_config<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<Captcha>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get captcha config

Source§

#### fn get_all_user_captchas<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<Captcha>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get all captchas belonging to user

Source§

#### fn update_captcha_metadata<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, p: &'life2 CreateCaptcha<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

update captcha metadata; doesn’t change captcha key

Source§

#### fn update_captcha_key<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, username: &'life1 str, old_key: &'life2 str, new_key: &'life3 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

update captcha key; doesn’t change metadata

Source§

#### fn add_captcha_levels<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, levels: &'life3 [Level], ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add levels to captcha

Source§

#### fn captcha_exists<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: Option<&'life1 str>, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

check if captcha exists

Source§

#### fn delete_captcha_levels<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete all levels of a captcha

Source§

#### fn delete_captcha<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete captcha

Source§

#### fn get_captcha_levels<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: Option<&'life1 str>, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<Level>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get captcha levels

Source§

#### fn get_captcha_cooldown<'life0, 'life1, 'async_trait>( &'life0 self, captcha_key: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<i32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get captcha’s cooldown period

Source§

#### fn add_traffic_pattern<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, pattern: &'life3 TrafficPattern, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Add traffic configuration

Source§

#### fn get_traffic_pattern<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<TrafficPattern>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get traffic configuration

Source§

#### fn delete_traffic_pattern<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, username: &'life1 str, captcha_key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Delete traffic configuration

Source§

#### fn create_notification<'life0, 'life1, 'async_trait>( &'life0 self, p: &'life1 AddNotification<'_>, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

create new notification

Source§

#### fn get_all_unread_notifications<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<Notification>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

get all unread notifications

Source§

#### fn mark_notification_read<'life0, 'life1, 'async_trait>( &'life0 self, username: &'life1 str, id: i32, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

mark a notification read

Source§

#### fn record_fetch<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

record PoWConfig fetches

Source§

#### fn record_solve<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

record PoWConfig solves

Source§

#### fn record_confirm<'life0, 'life1, 'async_trait>( &'life0 self, key: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

record PoWConfig confirms

Source§

#### fn fetch_config_fetched<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<i64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

fetch PoWConfig fetches

Source§

#### fn fetch_solve<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<i64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

fetch PoWConfig solves

Source§

#### fn fetch_confirm<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, user: &'life1 str, key: &'life2 str, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<i64>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

fetch PoWConfig confirms

Source§

#### fn analysis_save<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, captcha_id: &'life1 str, d: &'life2 CreatePerformanceAnalytics, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

record PoW timing

Source§

#### fn analytics_fetch<'life0, 'life1, 'async_trait>( &'life0 self, captcha_id: &'life1 str, limit: usize, offset: usize, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<PerformanceAnalytics>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

fetch PoW analytics

Source§

#### fn analytics_create_psuedo_id_if_not_exists<'life0, 'life1, 'async_trait>( &'life0 self, captcha_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Create psuedo ID against campaign ID to publish analytics

Source§

#### fn analytics_get_psuedo_id_from_capmaign_id<'life0, 'life1, 'async_trait>( &'life0 self, captcha_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get psuedo ID from campaign ID

Source§

#### fn analytics_get_capmaign_id_from_psuedo_id<'life0, 'life1, 'async_trait>( &'life0 self, psuedo_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get campaign ID from psuedo ID

Source§

#### fn analytics_get_all_psuedo_ids<'life0, 'async_trait>( &'life0 self, page: usize, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<String>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all psuedo IDs

Source§

#### fn update_max_nonce_for_level<'life0, 'life1, 'async_trait>( &'life0 self, captcha_key: &'life1 str, difficulty_factor: u32, latest_nonce: u32, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Track maximum nonce received against captcha levels

Source§

#### fn get_max_nonce_for_level<'life0, 'life1, 'async_trait>( &'life0 self, captcha_key: &'life1 str, difficulty_factor: u32, ) -> Pin<Box<dyn Future<Output = DBResult<u32>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get maximum nonce tracked so far for captcha levels

Source§

#### fn stats_get_num_logs_under_time<'life0, 'async_trait>( &'life0 self, duration: u32, ) -> Pin<Box<dyn Future<Output = DBResult<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get number of analytics entries that are under a certain duration

Source§

#### fn stats_get_entry_at_location_for_time_limit_asc<'life0, 'async_trait>( &'life0 self, duration: u32, location: u32, ) -> Pin<Box<dyn Future<Output = DBResult<Option<usize>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the entry at a location in the list of analytics entires under a certain time limited and sorted in ascending order

Source§

#### fn get_all_easy_captchas<'life0, 'async_trait>( &'life0 self, limit: usize, offset: usize, ) -> Pin<Box<dyn Future<Output = DBResult<Vec<EasyCaptcha>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all easy captcha configurations on instance

Source§

#### fn analytics_delete_all_records_for_campaign<'life0, 'life1, 'async_trait>( &'life0 self, campaign_id: &'life1 str, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete all records for campaign
§

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

Get publishing status of pow analytics for captcha ID/ campaign ID
Source§

### impl Migrate for Database

Source§

#### fn migrate<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = DBResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

database specific error-type run migrations

## Auto Trait Implementations§

§

### impl Freeze for Database

§

### impl !RefUnwindSafe for Database

§

### impl Send for Database

§

### impl Sync for Database

§

### impl Unpin for Database

§

### impl !UnwindSafe for Database

## Blanket Implementations§

Source§

### impl<T> Any for T
where T: 'static + ?Sized,

Source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
Source§

### impl<T> Borrow<T> for T
where T: ?Sized,

Source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

### impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

#### fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

### impl<T> CloneSPDatabase for T
where T: MCDatabase + Clone + 'static,

§

#### fn clone_db(&self) -> Box<dyn MCDatabase>

clone DB
Source§

### impl<T> CloneToUninit for T
where T: Clone,

Source§

#### unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (`clone_to_uninit`)
Performs copy-assignment from `self` to `dest`. Read more
Source§

### impl<T> From<T> for T

Source§

#### fn from(t: T) -> T

Returns the argument unchanged.

§

### impl<T> Instrument for T

§

#### fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [`Span`], returning an `Instrumented` wrapper. Read more
§

#### fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more
Source§

### impl<T, U> Into<U> for T
where U: From<T>,

Source§

#### fn into(self) -> U

Calls `U::from(self)`.

That is, this conversion is whatever the implementation of `From<T> for U` chooses to do.

Source§

### impl<T> IntoEither for T

Source§

#### fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left` is `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

#### fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts `self` into a `Left` variant of `Either<Self, Self>` if `into_left(&self)` returns `true`. Converts `self` into a `Right` variant of `Either<Self, Self>` otherwise. Read more
Source§

### impl<T> Same for T

Source§

#### type Output = T

Should always be `Self`
Source§

### impl<T> ToOwned for T
where T: Clone,

Source§

#### type Owned = T

The resulting type after obtaining ownership.
Source§

#### fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

#### fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

### impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

#### type Error = Infallible

The type returned in the event of a conversion error.
Source§

#### fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

### impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

#### type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

#### fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

### impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

#### fn vzip(self) -> V

§

### impl<T> WithSubscriber for T

§

#### fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided `Subscriber` to this type, returning a [`WithDispatch`] wrapper. Read more
§

#### fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default `Subscriber` to this type, returning a [`WithDispatch`] wrapper. Read more
§

### impl<T> ErasedDestructor for T
where T: 'static,

§

### impl<T> MaybeSendSync for T