diff --git a/src/main.rs b/src/main.rs index 4ccb876..60fd468 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,6 @@ use structopt::StructOpt; use std::{ path::PathBuf, - fs::File, - io::prelude::*, boxed::Box, error::Error, }; @@ -20,6 +18,8 @@ use sqlx::{ }; use tokio::{ sync::RwLock, + fs::File, + io::AsyncReadExt, }; const DEFAULT_DATABASE_PATH: &'static str = "/var/lib/noise-server/noise-server.sqlite"; @@ -67,7 +67,7 @@ async fn main() -> Result<(), Box> { return Ok(()); } - let mut config = get_config(&options)?; + let mut config = get_config(&options).await?; if clap_matches.is_present("database-path") { config.database_path = options.database_path; @@ -106,13 +106,13 @@ async fn load_sqlite_template(sqlite_handle: &mut SqliteConnection) -> sqlx::Res )).execute(sqlite_handle).await } -fn get_config(options: &Options) -> std::io::Result { +async fn get_config(options: &Options) -> std::io::Result { if options.no_config { Ok(Config::default()) } else { - let mut config_file = File::open(&options.config)?; + let mut config_file = File::open(&options.config).await?; let mut config_string = String::new(); - config_file.read_to_string(&mut config_string)?; + config_file.read_to_string(&mut config_string).await?; toml::from_str(&config_string) .map_err(|err| std::io::Error::new(