about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs2
-rw-r--r--src/service.rs (renamed from src/model.rs)0
-rw-r--r--src/smd/endpoints.rs1
-rw-r--r--src/smd/main.rs (renamed from src/bin/smd.rs)19
4 files changed, 13 insertions, 9 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 65880be..1f278a4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1 +1 @@
-pub mod model;
+pub mod service;
diff --git a/src/model.rs b/src/service.rs
index 60960e3..60960e3 100644
--- a/src/model.rs
+++ b/src/service.rs
diff --git a/src/smd/endpoints.rs b/src/smd/endpoints.rs
new file mode 100644
index 0000000..8b13789
--- /dev/null
+++ b/src/smd/endpoints.rs
@@ -0,0 +1 @@
+
diff --git a/src/bin/smd.rs b/src/smd/main.rs
index 5a8401a..231701b 100644
--- a/src/bin/smd.rs
+++ b/src/smd/main.rs
@@ -1,12 +1,12 @@
+mod endpoints;
+
 use clap::Parser;
 use serde::{Deserialize, Serialize};
-
 use tokio::fs::read_to_string;
+use salaryman::service::{Service, ServiceConf};
 
 use std::{net::IpAddr, path::PathBuf};
 
-use salaryman::model::{Service, ServiceConf};
-
 #[derive(Parser, Debug)]
 #[command(version, about, long_about = None)]
 struct Args {
@@ -42,6 +42,7 @@ struct Config {
     port: Option<u16>,
     service: Vec<ServiceConf>,
 }
+/*
 impl Config {
     fn new() -> Self {
         Self {
@@ -51,22 +52,23 @@ impl Config {
         }
     }
 }
+*/
 
-async fn load_config(file: &PathBuf) -> Config {
+async fn load_config(file: &PathBuf) -> Result<Config, Box<dyn std::error::Error>> {
     let s: String = match read_to_string(file).await {
         Ok(s) => s,
-        Err(_) => String::new(),
+        Err(_) => return Err(Box::new(std::io::Error::new(std::io::ErrorKind::NotFound, "cannot find config file"))),
     };
     match toml::from_str(s.as_str()) {
-        Ok(c) => c,
-        Err(_) => Config::new(),
+        Ok(c) => Ok(c),
+        Err(_) => Err(Box::new(std::io::Error::new(std::io::ErrorKind::Other, "unable to parse config file"))),
     }
 }
 
 #[tokio::main]
 async fn main() -> Result<(), Box<dyn std::error::Error>> {
     let args = Args::parse();
-    let conf: Config = load_config(&args.config).await;
+    let conf: Config = load_config(&args.config).await?;
     let mut services: Vec<Service> = Vec::new();
     for i in 0..conf.service.len() {
         services.push(Service::from_conf(&conf.service[i]));
@@ -90,3 +92,4 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
     }
     Ok(())
 }
+