printnanny-services 0.33.1

Library of MQTT, API, and other services used by PrintNanny
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use printnanny_edge_db::connection::run_migrations;
use printnanny_settings::printnanny::PrintNannySettings;

use crate::error::ServiceError;

// one-time PrintNanyn OS setup tasks
pub async fn printnanny_os_init() -> Result<(), ServiceError> {
    let settings = PrintNannySettings::new().await?;
    // ensure directory structure exists
    settings.paths.try_init_all()?;
    let sqlite_connection = settings.paths.db().display().to_string();
    // run any pending migrations
    run_migrations(&sqlite_connection).map_err(|e| ServiceError::SQLiteMigrationError {
        msg: (*e).to_string(),
    })?;
    Ok(())
}