Merge branch 'master' into fmt

This commit is contained in:
Daniel García
2021-04-15 18:24:04 +02:00
committed by GitHub
8 changed files with 79 additions and 25 deletions

View File

@ -478,7 +478,6 @@ pub fn retry<F, T, E>(func: F, max_tries: u32) -> Result<T, E>
where
F: Fn() -> Result<T, E>,
{
use std::{thread::sleep, time::Duration};
let mut tries = 0;
loop {
@ -497,12 +496,13 @@ where
}
}
use std::{thread::sleep, time::Duration};
pub fn retry_db<F, T, E>(func: F, max_tries: u32) -> Result<T, E>
where
F: Fn() -> Result<T, E>,
E: std::error::Error,
{
use std::{thread::sleep, time::Duration};
let mut tries = 0;
loop {
@ -522,3 +522,18 @@ where
}
}
}
use reqwest::{blocking::{Client, ClientBuilder}, header};
pub fn get_reqwest_client() -> Client {
get_reqwest_client_builder().build().expect("Failed to build client")
}
pub fn get_reqwest_client_builder() -> ClientBuilder {
let mut headers = header::HeaderMap::new();
headers.insert(header::USER_AGENT, header::HeaderValue::from_static("Bitwarden_RS"));
Client::builder()
.default_headers(headers)
.timeout(Duration::from_secs(10))
}