[][src]Struct my_iot::db::Db

pub struct Db {
    connection: Connection,
    _cache: CHashMap<String, Reading>,
}

A database connection.

Fields

connection: Connection

Wrapped SQLite connection.

_cache: CHashMap<String, Reading>

Readings cache. Stores the latest reading for each sensor.

Methods

impl Db[src]

pub fn new<P: AsRef<Path>>(path: P) -> Result<Db, Error>[src]

Create a new database connection.

impl Db[src]

Readings persistence.

pub fn insert_reading(&self, reading: &Reading) -> Result<(), Error>[src]

Insert reading into database.

pub fn select_latest_readings(&self) -> Result<Vec<Reading>, Error>[src]

Select latest reading for each sensor.

pub fn select_size(&self) -> Result<u64, Error>[src]

Select database size in bytes.

pub fn select_last_reading(
    &self,
    sensor: &str
) -> Result<Option<Reading>, Error>
[src]

Select the very last sensor reading.

pub fn select_readings(
    &self,
    sensor: &str,
    since: &DateTime<Local>
) -> Result<Vec<Reading>, Error>
[src]

Select the latest sensor readings within the given time interval.

impl Db[src]

Key-value store.

pub fn get<K, V>(&self, key: K) -> Result<Option<V>, Error> where
    K: AsRef<str>,
    V: SqliteTypeName + FromSql, 
[src]

Get an item from the key-value store.

pub fn set<K, V, E>(&self, key: K, value: V, expires_at: E) -> Result<(), Error> where
    K: AsRef<str>,
    V: SqliteTypeName + ToSql,
    E: Into<DateTime<Local>>, 
[src]

Set item in generic key-value store.

Auto Trait Implementations

impl Unpin for Db

impl Send for Db

impl !Sync for Db

impl UnwindSafe for Db

impl !RefUnwindSafe for Db

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T

impl<T> Erased for T

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

type Err = <U as TryFrom<T>>::Err

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