feat: 🔧 new structure for both tls and non-tls with config files and generics
This commit is contained in:
parent
1350046453
commit
9e8cc84f66
11 changed files with 207 additions and 103 deletions
23
streamer/src/utils.rs
Normal file
23
streamer/src/utils.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
use tokio::{fs::File, io::AsyncReadExt};
|
||||
|
||||
use crate::Config;
|
||||
|
||||
pub async fn get_config() -> Config {
|
||||
let mut config_file = File::open("configs/streamer_configs.txt").await.unwrap();
|
||||
let mut configs_unparsed = String::new();
|
||||
config_file.read_to_string(&mut configs_unparsed).await.unwrap();
|
||||
|
||||
let configs_parsed:Vec<&str> = configs_unparsed.split_terminator("\n").collect();
|
||||
let mut configs_cleaned: Vec<&str> = vec![];
|
||||
|
||||
for config in configs_parsed {
|
||||
let dirty_configs: Vec<&str> = config.split(": ").collect();
|
||||
configs_cleaned.push(dirty_configs[1]);
|
||||
}
|
||||
Config {
|
||||
address: configs_cleaned[0].to_string(),
|
||||
quality: configs_cleaned[1].parse().unwrap(),
|
||||
latency: configs_cleaned[2].parse().unwrap(),
|
||||
tls: configs_cleaned[3].parse().unwrap(),
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue