Struct modio_logger_db::Datastore
source · pub struct Datastore { /* private fields */ }Implementations
sourceimpl 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: String
) -> Result<(), Error>
pub async fn metadata_set_name(
&self,
key: &str,
name: String
) -> Result<(), 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: String
) -> Result<(), Error>
pub async fn metadata_set_unit(
&self,
key: &str,
unit: String
) -> Result<(), Error>
Set the unit for an key. If the unit is already set, will return some kind of Error.
sourcepub async fn metadata_set_description(
&self,
key: &str,
description: String
) -> Result<(), Error>
pub async fn metadata_set_description(
&self,
key: &str,
description: String
) -> Result<(), 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<(), Error>
pub async fn metadata_set_mode(
&self,
key: &str,
mode: SensorMode
) -> Result<(), Error>
Set the mode for a sensor. (ReadOnly, ReadWrite, WriteOnly)
If the mode was already set, replaces it.
sourceimpl 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
sourceimpl 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.
pub async fn persist_data(&self) -> Result<(), Error>
sourceimpl 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
sourceimpl 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>
pub async fn need_vacuum_or_shrink(&self) -> Result<usize, Error>
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Datastore
impl Send for Datastore
impl Sync for Datastore
impl Unpin for Datastore
impl !UnwindSafe for Datastore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more