derive/impl and use Default for some structs
and revamp HttpClientOptions with two constructors for the common use cases Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
committed by
Wolfgang Bumiller
parent
f4e52bb27d
commit
93e3581ce7
@ -52,15 +52,23 @@ pub struct HttpClientOptions {
|
||||
|
||||
impl HttpClientOptions {
|
||||
|
||||
pub fn new() -> Self {
|
||||
pub fn new_interactive(password: Option<String>, fingerprint: Option<String>) -> Self {
|
||||
Self {
|
||||
prefix: None,
|
||||
password: None,
|
||||
fingerprint: None,
|
||||
interactive: false,
|
||||
ticket_cache: false,
|
||||
fingerprint_cache: false,
|
||||
verify_cert: true,
|
||||
password,
|
||||
fingerprint,
|
||||
fingerprint_cache: true,
|
||||
ticket_cache: true,
|
||||
interactive: true,
|
||||
prefix: Some("proxmox-backup".to_string()),
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_non_interactive(password: String, fingerprint: Option<String>) -> Self {
|
||||
Self {
|
||||
password: Some(password),
|
||||
fingerprint,
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
|
||||
@ -100,6 +108,20 @@ impl HttpClientOptions {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for HttpClientOptions {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
prefix: None,
|
||||
password: None,
|
||||
fingerprint: None,
|
||||
interactive: false,
|
||||
ticket_cache: false,
|
||||
fingerprint_cache: false,
|
||||
verify_cert: true,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// HTTP(S) API client
|
||||
pub struct HttpClient {
|
||||
client: Client<HttpsConnector>,
|
||||
|
Reference in New Issue
Block a user