From 851ae4926fba296098fa5f08f99ba64622232ed2 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 12 Feb 2023 00:21:11 +0100 Subject: config path as arg --- src/config.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs index 6fc01d8..210a1e6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,7 +1,6 @@ -use std::{collections::HashMap, fs::read_to_string, net::SocketAddr, path::PathBuf}; - use anyhow::Context; use serde::{Deserialize, Serialize}; +use std::{collections::HashMap, fs::read_to_string, net::SocketAddr, path::PathBuf}; #[derive(Debug, Serialize, Deserialize)] pub struct Config { @@ -28,8 +27,8 @@ pub struct HostConfig { } impl Config { - pub fn load() -> anyhow::Result { - let raw = read_to_string("config.toml").context("reading config file")?; + pub fn load(path: &str) -> anyhow::Result { + let raw = read_to_string(path).context("reading config file")?; let config: Config = toml::from_str(&raw).context("parsing config")?; Ok(config) } -- cgit v1.2.3-70-g09d2