Struct modio_logger_db::Datastore
source · pub struct Datastore { /* private fields */ }
Implementations§
source§impl Datastore
impl Datastore
pub async fn has_transaction(&self, token: &str) -> Result<bool, Error>
pub async fn transaction_add( &self, key: &str, expected: &str, target: &str, token: &str ) -> Result<(), Error>
pub async fn transaction_get( &self, prefix: &str ) -> Result<Vec<Transaction>, Error>
pub async fn transaction_fail( &self, transaction_id: i64, timefail: bool ) -> Result<u64, Error>
pub async fn transaction_pass( &self, transaction_id: i64, timefail: bool ) -> Result<u64, Error>
sourcepub async fn transaction_fail_pending(&self) -> Result<u64, Error>
pub async fn transaction_fail_pending(&self) -> Result<u64, Error>
Fail all pending transactions
source§impl Datastore
impl Datastore
pub async fn delete_old_transactions(&self) -> Result<u64, Error>
pub async fn fail_queued_transactions(&self) -> Result<u64, Error>
pub async fn delete_old_logdata(&self) -> Result<u64, Error>
sourcepub async fn delete_random_data(&self) -> Result<u64, Error>
pub async fn delete_random_data(&self) -> Result<u64, Error>
Delete random data
pub async fn need_vacuum_or_shrink(&self) -> Result<usize, Error>
source§impl Datastore
impl Datastore
pub async fn metadata_get_names(&self) -> Result<Vec<Metadata>, Error>
pub async fn metadata_get_units(&self) -> Result<Vec<Metadata>, Error>
pub async fn metadata_get_descriptions(&self) -> Result<Vec<Metadata>, Error>
pub async fn metadata_get_enum(&self) -> Result<Vec<Metadata>, Error>
pub async fn get_metadata(&self, key: &str) -> Result<Option<Metadata>, Error>
pub async fn get_all_metadata(&self) -> Result<Vec<Metadata>, Error>
sourcepub async fn metadata_set_name(
&self,
key: &str,
name: &str
) -> Result<bool, Error>
pub async fn metadata_set_name( &self, key: &str, name: &str ) -> Result<bool, Error>
Set the name for a sensor If the name was already set, replaces it.
sourcepub async fn metadata_set_unit(
&self,
key: &str,
unit: &str
) -> Result<bool, Error>
pub async fn metadata_set_unit( &self, key: &str, unit: &str ) -> Result<bool, Error>
Set the unit for an key. If the unit is already set, will return some kind of Error. Returns true if it wrote to database, false if not
sourcepub async fn metadata_set_description(
&self,
key: &str,
description: &str
) -> Result<bool, Error>
pub async fn metadata_set_description( &self, key: &str, description: &str ) -> Result<bool, Error>
Set the description for a sensor If the description was already set, replaces it.
sourcepub async fn metadata_set_mode(
&self,
key: &str,
mode: &SensorMode
) -> Result<bool, Error>
pub async fn metadata_set_mode( &self, key: &str, mode: &SensorMode ) -> Result<bool, Error>
Set the mode for a sensor. (ReadOnly
, ReadWrite
, WriteOnly
)
If the mode was already set, replaces it.
source§impl Datastore
impl Datastore
sourcepub async fn new(pool: SqlitePool) -> Result<Self, Error>
pub async fn new(pool: SqlitePool) -> Result<Self, Error>
Construct a datastore Takes an pre-configured and migrated DB pool and opens a temp buffer.
Errors
Any SQLx
Error is returned.
pub fn pool(&self) -> SqlitePool
sourcepub async fn count_transactions(&self) -> Result<i64, Error>
pub async fn count_transactions(&self) -> Result<i64, Error>
Helper, count the remaining transaction in the table.
sourcepub async fn count_metrics(&self) -> Result<i32, Error>
pub async fn count_metrics(&self) -> Result<i32, Error>
Helper, count the amount of “customer” values in the database
sourcepub async fn count_metrics_internal(&self) -> Result<i32, Error>
pub async fn count_metrics_internal(&self) -> Result<i32, Error>
Helper, count the amount of “modio” values in the database
sourcepub async fn count_metrics_removed(&self) -> Result<i32, Error>
pub async fn count_metrics_removed(&self) -> Result<i32, Error>
Helper, count the amount of “deleted” values in the database
sourcepub async fn count_metrics_timefail(&self) -> Result<i32, Error>
pub async fn count_metrics_timefail(&self) -> Result<i32, Error>
Helper, count the amount of “timefail” values in the database
source§impl Datastore
impl Datastore
sourcepub async fn should_persist(&self) -> Result<bool, Error>
pub async fn should_persist(&self) -> Result<bool, Error>
sourcepub async fn should_persist_age(&self) -> Result<bool, Error>
pub async fn should_persist_age(&self) -> Result<bool, Error>
Check if we should persist data to disk according to age heurestic
Errors
Any SQL errors are returned.
sourcepub async fn should_persist_key(&self, key: &str) -> Result<bool, Error>
pub async fn should_persist_key(&self, key: &str) -> Result<bool, Error>
Check if we need to persist data to have current data for this key
Errors
Key missing or other SQL error.