From 5cd027d271a00d2308c5b1a076aaa35bd5c4e3a5 Mon Sep 17 00:00:00 2001 From: Ishan Jain Date: Mon, 18 Apr 2022 01:33:01 +0530 Subject: [PATCH] removed tracing/color-eyre and added thiserror --- Cargo.lock | 232 +++---------------------------------- Cargo.toml | 5 +- src/client.rs | 16 ++- src/interface/interface.rs | 15 ++- src/ip/dhcp_server.rs | 23 ++-- src/system/health.rs | 13 ++- tests/interfaces_test.rs | 40 ++----- tests/ip_test.rs | 68 +++-------- tests/system_test.rs | 33 +----- 9 files changed, 103 insertions(+), 342 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e68f160..f2c8037 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,30 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "addr2line" -version = "0.17.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" -dependencies = [ - "gimli", -] - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "async-stream" version = "0.3.3" @@ -53,21 +29,6 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" -[[package]] -name = "backtrace" -version = "0.3.64" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e121dee8023ce33ab248d9ce1493df03c3b38a659b240096fcbd7048ff9c31f" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide", - "object", - "rustc-demangle", -] - [[package]] name = "base64" version = "0.13.0" @@ -104,33 +65,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "color-eyre" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ebf286c900a6d5867aeff75cfee3192857bb7f24b547d4f0df2ed6baa812c90" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ba75b3d9449ecdccb27ecbc479fdc0b87fa2dd43d2f8298f9bf0e59aacc8dce" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "core-foundation" version = "0.9.3" @@ -156,16 +90,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "eyre" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c2b6b5a29c02cdc822728b7d7b8ae1bab3e3b05d44522770ddd49722eeac7eb" -dependencies = [ - "indenter", - "once_cell", -] - [[package]] name = "fastrand" version = "1.7.0" @@ -295,12 +219,6 @@ dependencies = [ "slab", ] -[[package]] -name = "gimli" -version = "0.26.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" - [[package]] name = "h2" version = "0.3.13" @@ -430,12 +348,6 @@ dependencies = [ "unicode-normalization", ] -[[package]] -name = "indenter" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" - [[package]] name = "indexmap" version = "1.8.1" @@ -507,15 +419,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata", -] - [[package]] name = "matches" version = "0.1.9" @@ -530,17 +433,17 @@ checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" [[package]] name = "mikrotik" -version = "0.0.2" +version = "0.0.3" dependencies = [ "base64", - "color-eyre", "futures", "reqwest", "serde", "serde_derive", + "thiserror", "tokio", "tokio-test", - "tracing-subscriber", + "url", ] [[package]] @@ -549,16 +452,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" -[[package]] -name = "miniz_oxide" -version = "0.4.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" -dependencies = [ - "adler", - "autocfg", -] - [[package]] name = "mio" version = "0.8.2" @@ -619,15 +512,6 @@ dependencies = [ "libc", ] -[[package]] -name = "object" -version = "0.27.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67ac1d3f9a1d3616fd9a60c8d74296f22406a238b6a72f5cc1e6f314df4ffbf9" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.10.0" @@ -667,12 +551,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "owo-colors" -version = "3.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e72e30578e0d0993c8ae20823dd9cff2bc5517d2f586a8aef462a581e8a03eb" - [[package]] name = "parking_lot" version = "0.12.0" @@ -747,30 +625,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.5.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a11647b6b25ff05a515cb92c365cec08801e83423a235b51e231e1808747286" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.25" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" - [[package]] name = "remove_dir_all" version = "0.5.3" @@ -836,12 +690,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "rustc-demangle" -version = "0.1.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" - [[package]] name = "rustls" version = "0.20.4" @@ -961,15 +809,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sharded-slab" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" -dependencies = [ - "lazy_static", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1033,12 +872,23 @@ dependencies = [ ] [[package]] -name = "thread_local" -version = "1.1.4" +name = "thiserror" +version = "1.0.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" dependencies = [ - "once_cell", + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -1182,46 +1032,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f54c8ca710e81886d498c2fd3331b56c93aa248d49de2222ad2742247c60072f" dependencies = [ "lazy_static", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-log" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a6923477a48e41c1951f1999ef8bb5a3023eb723ceadafe78ffb65dc366761e3" -dependencies = [ - "lazy_static", - "log", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bc28f93baff38037f64e6f43d34cfa1605f27a49c34e8a04c5e78b0babf2596" -dependencies = [ - "ansi_term", - "lazy_static", - "matchers", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", ] [[package]] @@ -1269,12 +1079,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "vcpkg" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index dfb6fb6..edc69af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,18 +4,17 @@ version = "0.0.3" edition = "2021" description = "REST API Wrapper for Mikrotik API" license = "MIT" -license-file = "LICENSE" [dev-dependencies] tokio-test = "0.4.2" -tracing-subscriber = { version = "0.3.11", features = ["env-filter"] } [dependencies] base64 = "0.13.0" -color-eyre = "0.6.1" futures = "0.3.17" reqwest = { version = "0.11.4", features = ["rustls-tls", "serde_json", "json"] } serde = { version = "1.0.130", features = ["derive"] } serde_derive = "1.0.136" +thiserror = "1.0.30" tokio = { version = "1.10.1", features = ["full"] } +url = "2.2.2" diff --git a/src/client.rs b/src/client.rs index 7d973a2..fade523 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1,8 +1,8 @@ -use color_eyre::Report; use reqwest::{ header::{HeaderMap, HeaderValue}, Request, Url, }; +use thiserror::Error; pub struct Client { pub client: reqwest::Client, @@ -17,7 +17,7 @@ impl Client { username: String, password: String, self_signed_cert: bool, - ) -> Result { + ) -> Result { let value = format!("{}:{}", username, password); let value = base64::encode(value); @@ -49,3 +49,15 @@ impl Client { self.client.execute(r).await } } + +#[derive(Debug, Error)] +pub enum ClientError { + #[error(transparent)] + InvalidHeaderValue(#[from] reqwest::header::InvalidHeaderValue), + + #[error(transparent)] + UrlError(#[from] url::ParseError), + + #[error(transparent)] + ReqwestError(#[from] reqwest::Error), +} diff --git a/src/interface/interface.rs b/src/interface/interface.rs index 62178e9..3ffe334 100644 --- a/src/interface/interface.rs +++ b/src/interface/interface.rs @@ -1,8 +1,17 @@ use crate::{interface::types::Interface, Client}; -use color_eyre::Report; use reqwest::{Method, Request}; +use thiserror::Error; -pub async fn list(client: &mut Client) -> Result, Report> { +#[derive(Error, Debug)] +pub enum InterfaceError { + #[error(transparent)] + UrlError(#[from] url::ParseError), + + #[error(transparent)] + ReqwestError(#[from] reqwest::Error), +} + +pub async fn list(client: &mut Client) -> Result, InterfaceError> { let url = client.base_url.clone(); let url = url.join(super::BASE)?; @@ -13,7 +22,7 @@ pub async fn list(client: &mut Client) -> Result, Report> { Ok(response) } -pub async fn get(client: &mut Client, ifid: &str) -> Result { +pub async fn get(client: &mut Client, ifid: &str) -> Result { let url = client.base_url.clone(); let url = url.join(&format!("{}/{}", super::BASE, ifid))?; diff --git a/src/ip/dhcp_server.rs b/src/ip/dhcp_server.rs index bcd3684..36dea29 100644 --- a/src/ip/dhcp_server.rs +++ b/src/ip/dhcp_server.rs @@ -2,10 +2,10 @@ use crate::{ ip::types::{DhcpServer, Lease, Network}, Client, }; -use color_eyre::Report; use reqwest::{Method, Request}; +use thiserror::Error; -pub async fn list(client: &mut Client) -> Result, Report> { +pub async fn list(client: &mut Client) -> Result, DhcpServerError> { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server", super::BASE))?; let req = Request::new(Method::GET, url); @@ -14,7 +14,7 @@ pub async fn list(client: &mut Client) -> Result, Report> { Ok(response) } -pub async fn get(client: &mut Client, dhcp_server_id: &str) -> Result { +pub async fn get(client: &mut Client, dhcp_server_id: &str) -> Result { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server/{}", super::BASE, dhcp_server_id))?; let req = Request::new(Method::GET, url); @@ -23,7 +23,7 @@ pub async fn get(client: &mut Client, dhcp_server_id: &str) -> Result Result, Report> { +pub async fn list_network(client: &mut Client) -> Result, DhcpServerError> { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server/network", super::BASE))?; let req = Request::new(Method::GET, url); @@ -32,7 +32,7 @@ pub async fn list_network(client: &mut Client) -> Result, Report> { Ok(response) } -pub async fn get_network(client: &mut Client, nid: &str) -> Result { +pub async fn get_network(client: &mut Client, nid: &str) -> Result { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server/network/{}", super::BASE, nid))?; let req = Request::new(Method::GET, url); @@ -41,7 +41,7 @@ pub async fn get_network(client: &mut Client, nid: &str) -> Result Result, Report> { +pub async fn list_leases(client: &mut Client) -> Result, DhcpServerError> { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server/lease", super::BASE))?; let req = Request::new(Method::GET, url); @@ -50,7 +50,7 @@ pub async fn list_leases(client: &mut Client) -> Result, Report> { Ok(response) } -pub async fn get_lease(client: &mut Client, lease_id: &str) -> Result { +pub async fn get_lease(client: &mut Client, lease_id: &str) -> Result { let url = client.base_url.clone(); let url = url.join(&format!("{}/dhcp-server/lease/{}", super::BASE, lease_id))?; let req = Request::new(Method::GET, url); @@ -58,3 +58,12 @@ pub async fn get_lease(client: &mut Client, lease_id: &str) -> Result Result, Report> { +#[derive(Error, Debug)] +pub enum HealthError { + #[error(transparent)] + UrlError(#[from] url::ParseError), + + #[error(transparent)] + ReqwestError(#[from] reqwest::Error), +} + +pub async fn health(client: &mut Client) -> Result, HealthError> { let url = client.base_url.clone(); let url = url.join(&format!("{}/health", super::BASE))?; diff --git a/tests/interfaces_test.rs b/tests/interfaces_test.rs index f97aa16..6c5b976 100644 --- a/tests/interfaces_test.rs +++ b/tests/interfaces_test.rs @@ -1,36 +1,11 @@ -use color_eyre::Report; -use mikrotik::Client; +use mikrotik::{interface::InterfaceError, Client}; use reqwest::Url; -use std::sync::Once; -use tracing_subscriber::EnvFilter; - -static INIT: Once = Once::new(); - -fn setup() -> Result<(), Report> { - INIT.call_once(|| { - if std::env::var("RUST_LIB_BACKTRACE").is_err() { - std::env::set_var("RUST_LIB_BACKTRACE", "1") - } - color_eyre::install(); - - if std::env::var("RUST_LOG").is_err() { - std::env::set_var("RUST_LOG", "info"); - } - - tracing_subscriber::fmt::fmt() - .with_env_filter(EnvFilter::from_default_env()) - .init(); - }); - - Ok(()) -} #[tokio::test] -async fn list_interfaces() -> Result<(), Report> { - setup()?; - +async fn list_interfaces() -> Result<(), InterfaceError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::interface::list(&mut client).await?; @@ -40,11 +15,10 @@ async fn list_interfaces() -> Result<(), Report> { } #[tokio::test] -async fn get_interface() -> Result<(), Report> { - setup()?; - +async fn get_interface() -> Result<(), InterfaceError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::interface::get(&mut client, "ether5").await?; diff --git a/tests/ip_test.rs b/tests/ip_test.rs index 1b67b19..0a8ccde 100644 --- a/tests/ip_test.rs +++ b/tests/ip_test.rs @@ -1,36 +1,11 @@ -use color_eyre::Report; -use mikrotik::Client; +use mikrotik::{ip::dhcp_server::DhcpServerError, Client}; use reqwest::Url; -use std::sync::Once; -use tracing_subscriber::EnvFilter; - -static INIT: Once = Once::new(); - -fn setup() -> Result<(), Report> { - INIT.call_once(|| { - if std::env::var("RUST_LIB_BACKTRACE").is_err() { - std::env::set_var("RUST_LIB_BACKTRACE", "1") - } - color_eyre::install(); - - if std::env::var("RUST_LOG").is_err() { - std::env::set_var("RUST_LOG", "info"); - } - - tracing_subscriber::fmt::fmt() - .with_env_filter(EnvFilter::from_default_env()) - .init(); - }); - - Ok(()) -} #[tokio::test] -async fn list_dhcp_servers() -> Result<(), Report> { - setup()?; - +async fn list_dhcp_servers() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::list(&mut client).await?; @@ -40,11 +15,10 @@ async fn list_dhcp_servers() -> Result<(), Report> { } #[tokio::test] -async fn get_dhcp_server() -> Result<(), Report> { - setup()?; - +async fn get_dhcp_server() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::get(&mut client, "vlan-150").await?; @@ -54,11 +28,10 @@ async fn get_dhcp_server() -> Result<(), Report> { } #[tokio::test] -async fn list_network() -> Result<(), Report> { - setup()?; - +async fn list_network() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::list_network(&mut client).await?; @@ -68,11 +41,10 @@ async fn list_network() -> Result<(), Report> { } #[tokio::test] -async fn get_network() -> Result<(), Report> { - setup()?; - +async fn get_network() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::list_network(&mut client).await?; @@ -84,11 +56,10 @@ async fn get_network() -> Result<(), Report> { } #[tokio::test] -async fn list_leases() -> Result<(), Report> { - setup()?; - +async fn list_leases() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::list_leases(&mut client).await?; @@ -98,11 +69,10 @@ async fn list_leases() -> Result<(), Report> { } #[tokio::test] -async fn get_lease() -> Result<(), Report> { - setup()?; - +async fn get_lease() -> Result<(), DhcpServerError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::ip::dhcp_server::list_leases(&mut client).await?; diff --git a/tests/system_test.rs b/tests/system_test.rs index b0c67ed..b63180a 100644 --- a/tests/system_test.rs +++ b/tests/system_test.rs @@ -1,36 +1,11 @@ -use color_eyre::Report; -use mikrotik::Client; +use mikrotik::{system::HealthError, Client}; use reqwest::Url; -use std::sync::Once; -use tracing_subscriber::EnvFilter; - -static INIT: Once = Once::new(); - -fn setup() -> Result<(), Report> { - INIT.call_once(|| { - if std::env::var("RUST_LIB_BACKTRACE").is_err() { - std::env::set_var("RUST_LIB_BACKTRACE", "1") - } - color_eyre::install(); - - if std::env::var("RUST_LOG").is_err() { - std::env::set_var("RUST_LOG", "info"); - } - - tracing_subscriber::fmt::fmt() - .with_env_filter(EnvFilter::from_default_env()) - .init(); - }); - - Ok(()) -} #[tokio::test] -async fn health() -> Result<(), Report> { - setup()?; - +async fn health() -> Result<(), HealthError> { let base = Url::parse("https://10.0.10.1")?; - let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true)?; + let mut client = Client::new(base, "admin".to_string(), "ifd783far".to_string(), true) + .expect("error in creating client"); let response = mikrotik::system::health(&mut client).await?;