use dsh_api::dsh_api_client::DshApiClient;
use dsh_api::dsh_api_client_factory::DshApiClientFactory;
use dsh_api::error::DshApiResult;
use std::io::Write;
#[allow(dead_code)]
fn main() {}
#[allow(unused)]
pub fn initialize_logger(header: Option<&str>) {
header.inspect(|h| print_header(h));
env_logger::builder()
.format(|f, r| {
writeln!(
f,
"[{:5}] {} [{}:{}]",
r.level(),
r.args(),
r.target(),
r.line().map(|line| line.to_string()).unwrap_or_default()
)
})
.try_init();
}
#[allow(unused)]
pub fn print_header(header: &str) {
let bar = (0..header.len()).map(|_| "-").collect::<String>();
println!("\n{}\n{}\n{}", bar, header, bar);
}
#[allow(unused)]
pub async fn get_client<'a>() -> Result<DshApiClient, String> {
let try_factory: DshApiResult<DshApiClientFactory> = DshApiClientFactory::try_default();
match try_factory {
Ok(factory) => match factory.client().await {
Ok(client) => Ok(client),
Err(error) => Err(format!("could not create client ({})", error)),
},
Err(error) => Err(format!("could not create client factory ({})", error)),
}
}