[pbs-devel] [PATCH proxmox v2 09/12] auth-api: remove lazy_static dependency

Maximiliano Sandoval m.sandoval at proxmox.com
Wed Aug 14 09:19:58 CEST 2024


Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 proxmox-auth-api/Cargo.toml   |  4 ++--
 proxmox-auth-api/src/types.rs | 11 ++++-------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/proxmox-auth-api/Cargo.toml b/proxmox-auth-api/Cargo.toml
index 44db2bf8..62c173ad 100644
--- a/proxmox-auth-api/Cargo.toml
+++ b/proxmox-auth-api/Cargo.toml
@@ -7,6 +7,7 @@ license.workspace = true
 repository.workspace = true
 exclude.workspace = true
 description = "Tickets, API and Realm handling"
+rust-version.workspace = true
 
 [[example]]
 name = "passwd"
@@ -16,7 +17,6 @@ required-features = [ "pam-authenticator" ]
 anyhow.workspace = true
 const_format = { workspace = true, optional = true }
 base64 = { workspace = true, optional = true }
-lazy_static = { workspace = true, optional = true }
 libc = { workspace = true, optional = true }
 log = { workspace = true, optional = true }
 http = { workspace = true, optional = true }
@@ -40,7 +40,7 @@ proxmox-tfa = { workspace = true, optional = true, features = [ "api" ] }
 default = []
 
 ticket = [ "dep:base64", "dep:percent-encoding", "dep:openssl" ]
-api-types = [ "dep:const_format", "dep:lazy_static", "dep:regex", "dep:serde", "dep:serde_plain", "dep:proxmox-schema" ]
+api-types = [ "dep:const_format", "dep:regex", "dep:serde", "dep:serde_plain", "dep:proxmox-schema" ]
 api = [
     "api-types",
     "ticket",
diff --git a/proxmox-auth-api/src/types.rs b/proxmox-auth-api/src/types.rs
index 25e5feff..64c580a5 100644
--- a/proxmox-auth-api/src/types.rs
+++ b/proxmox-auth-api/src/types.rs
@@ -23,10 +23,10 @@
 
 use std::borrow::Borrow;
 use std::fmt;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
 use const_format::concatcp;
-use lazy_static::lazy_static;
 use serde::{Deserialize, Serialize};
 
 use proxmox_schema::{
@@ -454,9 +454,7 @@ impl Userid {
     }
 }
 
-lazy_static! {
-    pub static ref ROOT_USERID: Userid = Userid::new("root at pam".to_string(), 4);
-}
+pub static ROOT_USERID: LazyLock<Userid> = LazyLock::new(|| Userid::new("root at pam".to_string(), 4));
 
 impl From<Authid> for Userid {
     fn from(authid: Authid) -> Self {
@@ -587,9 +585,8 @@ impl Authid {
     }
 }
 
-lazy_static! {
-    pub static ref ROOT_AUTHID: Authid = Authid::from(Userid::new("root at pam".to_string(), 4));
-}
+pub static ROOT_AUTHID: LazyLock<Authid> =
+    LazyLock::new(|| Authid::from(Userid::new("root at pam".to_string(), 4)));
 
 impl From<Userid> for Authid {
     fn from(parts: Userid) -> Self {
-- 
2.39.2





More information about the pbs-devel mailing list