diff --git a/Cargo.toml b/Cargo.toml index 560024d..3a746b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,13 +19,11 @@ serde_yaml = "0.9.21" clap = {version = "4.3.8", features = ["derive", "cargo"]} thiserror = "1.0.40" rand = "0.8.5" -isahc = "1.7" +reqwest = { version = "0.12.5", default-features = false, features = ["rustls-tls"] } phf = { version = "0.11", features = ["macros"] } # linked list to store the containers in the order they appear in the docker-compose.yaml indexmap = { version = "2.0.0", features = ["serde"] } - -# https://github.com/sfackler/rust-openssl/issues/1021 -openssl = { version = "0.10", features = ["vendored"] } +tokio = { version = "1", features = ["macros", "rt-multi-thread"] } [profile.release] debug = false \ No newline at end of file diff --git a/src/file_utils.rs b/src/file_utils.rs index 90f2ccd..2c271b3 100644 --- a/src/file_utils.rs +++ b/src/file_utils.rs @@ -1,8 +1,6 @@ use std::io::Read; use std::{fs::File, process::exit}; -use isahc::ReadResponseExt; - use serde_yaml::{Mapping, Value}; use crate::exporters::excalidraw_config::DEFAULT_CONFIG; @@ -30,8 +28,8 @@ pub fn get_excalidraw_config(file_path: &str) -> ExcalidrawConfig { } } -pub fn get_docker_compose_content(file_path: &str) -> Mapping { - let file_content = match get_file_content(file_path) { +pub async fn get_docker_compose_content(file_path: &str) -> Mapping { + let file_content = match get_file_content(file_path).await { Ok(content) => content, Err(err) => { println!("{}", err); @@ -81,10 +79,10 @@ fn read_yaml_file(file_path: &str) -> Result { /// Get file content as a String. /// Both remote (f.e. from Github) and local files are supported -fn get_file_content(file_path: &str) -> Result { +async fn get_file_content(file_path: &str) -> Result { if file_path.starts_with("http") { let url = rewrite_github_url(file_path); - let mut response = match isahc::get(url) { + let response = match reqwest::get(url).await { Ok(rs) => rs, Err(err) => { return Err(RemoteFileFailedRead { @@ -93,7 +91,7 @@ fn get_file_content(file_path: &str) -> Result { }) } }; - match response.text() { + match response.text().await { Ok(data) => Ok(data), Err(err) => Err(RemoteFileFailedRead { path: file_path.to_string(), diff --git a/src/main.rs b/src/main.rs index 7a44800..d4626aa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -139,7 +139,8 @@ struct RectangleStruct { pub bound_elements: Vec, } -fn main() { +#[tokio::main] +async fn main() { let cli = Cli::parse(); let excalidraw_config: ExcalidrawConfig = file_utils::get_excalidraw_config(cli.config_path.as_str()); @@ -164,7 +165,7 @@ fn main() { let input_path = &cli.input_path.unwrap(); let input_filepath = input_path.as_str(); - let docker_compose_yaml = file_utils::get_docker_compose_content(input_filepath); + let docker_compose_yaml = file_utils::get_docker_compose_content(input_filepath).await; let alignment_mode = excalidraw_config.alignment.mode.as_str(); let (x_margin, y_margin, x_alignment_factor, y_alignment_factor) = margins(alignment_mode);