From bea97ccce1e53993767f87f5894da91b5f972b63 Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 10 Aug 2023 14:14:06 +0200 Subject: [PATCH] client: add Client::set_authentication method Signed-off-by: Wolfgang Bumiller --- proxmox-client/src/client.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/proxmox-client/src/client.rs b/proxmox-client/src/client.rs index c49cee41..b9d5377f 100644 --- a/proxmox-client/src/client.rs +++ b/proxmox-client/src/client.rs @@ -133,9 +133,17 @@ impl Client { self.auth.lock().unwrap().clone() } + #[deprecated(note = "use set_authentication instead")] /// Replace the authentication information with an API token. pub fn use_api_token(&self, token: Token) { - *self.auth.lock().unwrap() = Some(Arc::new(token.into())); + self.set_authentication(token); + } + + /// Replace the currently used authentication. + /// + /// This can be a `Token` or an [`Authentication`](proxmox_login::Authentication). + pub fn set_authentication(&self, auth: impl Into) { + *self.auth.lock().unwrap() = Some(Arc::new(auth.into())); } /// Drop the current authentication information.