-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
mod config; | ||
|
||
use config::Config; | ||
use std::fs::File; | ||
use std::io::Read; | ||
|
||
fn load_config() -> Result<Config, Box<dyn std::error::Error>> { | ||
let mut file = File::open("config.yaml")?; | ||
let mut content = String::new(); | ||
|
||
file.read_to_string(&mut content)?; | ||
let config: Config = serde_yaml::from_str(&content)?; | ||
|
||
Ok(config) | ||
} | ||
|
||
// test case for load_config | ||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_load_config() { | ||
let config = load_config().unwrap(); | ||
assert_eq!(config.interface, "enp3s0"); | ||
assert_eq!(config.rules.len(), 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
mod server; | ||
mod config; | ||
|
||
use server::Server; | ||
|
||
fn main() { | ||
|