Implementation of firmware for a sprinklers system using async Rust, Tokio, Actix, MQTT and more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
986 B

5 years ago
use color_eyre::eyre::Result;
use rusqlite::Connection as DbConnection;
use rusqlite::NO_PARAMS;
use tracing::info;
5 years ago
mod db;
mod migrations;
mod model;
mod section_interface;
mod section_runner;
#[cfg(test)]
mod trace_listeners;
use model::Section;
5 years ago
fn setup_db() -> Result<DbConnection> {
5 years ago
// let conn = DbConnection::open_in_memory()?;
let mut conn = DbConnection::open("test.db")?;
let migs = db::create_migrations();
migs.apply(&mut conn)?;
Ok(conn)
}
fn query_sections(conn: &DbConnection) -> Result<Vec<Section>> {
let mut statement = conn.prepare_cached("SELECT id, name, interface_id FROM sections;")?;
let rows = statement.query_map(NO_PARAMS, Section::from_sql)?;
Ok(rows.collect::<Result<Vec<_>, _>>()?)
5 years ago
}
fn main() -> Result<()> {
env_logger::init();
color_eyre::install()?;
let conn = setup_db()?;
let sections = query_sections(&conn)?;
for sec in sections {
info!("section: {:?}", sec);
}
5 years ago
Ok(())
}