From 4c7359531d779380027c44f015d96413f0510d01 Mon Sep 17 00:00:00 2001 From: Gregor Reitzenstein Date: Tue, 26 Jan 2021 14:38:37 +0000 Subject: [PATCH] Finally switch over to Config instead of Settings --- src/config.rs | 3 --- src/db/access/internal.rs | 4 ++-- src/db/machine.rs | 4 ++-- src/db/user/internal.rs | 2 +- src/machine.rs | 2 +- src/server.rs | 4 ++-- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/config.rs b/src/config.rs index b240c59..7b9c060 100644 --- a/src/config.rs +++ b/src/config.rs @@ -15,9 +15,6 @@ pub fn read(path: &Path) -> Result { .map_err(Into::into) } -#[deprecated] -pub type Settings = Config; - #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Config { /// A list of address/port pairs to listen on. diff --git a/src/db/access/internal.rs b/src/db/access/internal.rs index b5bf0af..aa22674 100644 --- a/src/db/access/internal.rs +++ b/src/db/access/internal.rs @@ -8,7 +8,7 @@ use flexbuffers; use slog::Logger; use lmdb::{Environment, Transaction, RwTransaction, Cursor}; -use crate::config::Settings; +use crate::config::Config; use crate::error::Result; use crate::db::access::{Permission, Role, RoleIdentifier, RoleDB}; @@ -163,7 +163,7 @@ impl RoleDB for Internal { /// Initialize the access db by loading all the lmdb databases -pub fn init(log: Logger, config: &Settings, env: Arc) +pub fn init(log: Logger, config: &Config, env: Arc) -> std::result::Result { let mut flags = lmdb::DatabaseFlags::empty(); diff --git a/src/db/machine.rs b/src/db/machine.rs index 5ebbc81..0d1c404 100644 --- a/src/db/machine.rs +++ b/src/db/machine.rs @@ -5,7 +5,7 @@ use serde::{Serialize, Deserialize}; use std::sync::Arc; use crate::error::Result; -use crate::config::Settings; +use crate::config::Config; use uuid::Uuid; @@ -68,7 +68,7 @@ impl MachineState { } } -pub fn init(log: Logger, config: &Settings, env: Arc) -> Result { +pub fn init(log: Logger, config: &Config, env: Arc) -> Result { let mut flags = lmdb::DatabaseFlags::empty(); flags.set(lmdb::DatabaseFlags::INTEGER_KEY, true); let machdb = env.create_db(Some("machines"), flags)?; diff --git a/src/db/user/internal.rs b/src/db/user/internal.rs index 938ee23..2f3aeb6 100644 --- a/src/db/user/internal.rs +++ b/src/db/user/internal.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use slog::Logger; -use lmdb::{Environment, Cursor, Transaction, RwTransaction}; +use lmdb::{Environment, Transaction, RwTransaction}; use crate::error::Result; diff --git a/src/machine.rs b/src/machine.rs index 92c07c4..527db26 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -245,7 +245,7 @@ impl MachineDescription { } } -pub fn load(config: &crate::config::Settings, access: Arc) +pub fn load(config: &crate::config::Config, access: Arc) -> Result { let mut map = config.machines.clone(); diff --git a/src/server.rs b/src/server.rs index 38fc533..32a789e 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,7 +1,7 @@ use slog::Logger; use crate::config; -use crate::config::Settings; +use crate::config::Config; use crate::error::Error; use crate::connection; @@ -19,7 +19,7 @@ use crate::db::Databases; use crate::network::Network; /// Handle all API connections and run the RPC tasks spawned from that on the local thread. -pub fn serve_api_connections(log: Arc, config: Settings, db: Databases, nw: Network) +pub fn serve_api_connections(log: Arc, config: Config, db: Databases, nw: Network) -> Result<(), Error> { let signal = Box::pin(async {