public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80
@ 2024-08-14  7:19 Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency Maximiliano Sandoval
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

In the following commits we make use of std::sync::LazyLock;

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
Differences from v1:
 - Remove changes to d/control

 Cargo.toml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index 6495b40a..71f25b45 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -59,7 +59,7 @@ license = "AGPL-3"
 repository = "https://git.proxmox.com/?p=proxmox.git"
 homepage = "https://proxmox.com"
 exclude = [ "debian" ]
-rust-version = "1.70"
+rust-version = "1.80"
 
 [workspace.dependencies]
 # any features enabled here are enabled on all members using 'workspace = true'!
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 03/12] async: remove lazy_static dependency Maximiliano Sandoval
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-dns-api/Cargo.toml         |  2 +-
 proxmox-dns-api/src/resolv_conf.rs | 17 ++++++-----------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/proxmox-dns-api/Cargo.toml b/proxmox-dns-api/Cargo.toml
index 406c9466..98045b34 100644
--- a/proxmox-dns-api/Cargo.toml
+++ b/proxmox-dns-api/Cargo.toml
@@ -7,11 +7,11 @@ license.workspace = true
 repository.workspace = true
 exclude.workspace = true
 description = "DNS Management API implementation"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 const_format.workspace = true
-lazy_static.workspace = true
 regex.workspace = true
 serde = { workspace = true, features = ["derive"] }
 
diff --git a/proxmox-dns-api/src/resolv_conf.rs b/proxmox-dns-api/src/resolv_conf.rs
index 1b09d07f..32698913 100644
--- a/proxmox-dns-api/src/resolv_conf.rs
+++ b/proxmox-dns-api/src/resolv_conf.rs
@@ -1,9 +1,7 @@
-use std::sync::Arc;
-use std::sync::Mutex;
+use std::sync::{Arc, LazyLock, Mutex};
 
 use anyhow::Error;
 use const_format::concatcp;
-use lazy_static::lazy_static;
 use proxmox_config_digest::ConfigDigest;
 use regex::Regex;
 
@@ -34,11 +32,10 @@ pub fn read_etc_resolv_conf(
 
     let data = String::from_utf8(raw)?;
 
-    lazy_static! {
-        static ref DOMAIN_REGEX: Regex = Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap();
-        static ref SERVER_REGEX: Regex =
-            Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap();
-    }
+    static DOMAIN_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(r"^\s*(?:search|domain)\s+(\S+)\s*").unwrap());
+    static SERVER_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^\s*nameserver\s+(", IPRE_STR, r")\s*")).unwrap());
 
     let mut options = String::new();
 
@@ -78,9 +75,7 @@ pub fn update_dns(
     delete: Option<Vec<DeletableResolvConfProperty>>,
     digest: Option<ConfigDigest>,
 ) -> Result<(), Error> {
-    lazy_static! {
-        static ref MUTEX: Arc<Mutex<()>> = Arc::new(Mutex::new(()));
-    }
+    static MUTEX: LazyLock<Arc<Mutex<()>>> = LazyLock::new(|| Arc::new(Mutex::new(())));
 
     let _guard = MUTEX.lock();
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 03/12] async: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 04/12] subscription: " Maximiliano Sandoval
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-async/Cargo.toml     |  2 +-
 proxmox-async/src/runtime.rs | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/proxmox-async/Cargo.toml b/proxmox-async/Cargo.toml
index 669ae08b..8508ef5d 100644
--- a/proxmox-async/Cargo.toml
+++ b/proxmox-async/Cargo.toml
@@ -6,13 +6,13 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "Proxmox async/tokio helpers"
+rust-version.workspace = true
 
 exclude.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 futures.workspace = true
-lazy_static.workspace = true
 pin-utils.workspace = true
 tokio = { workspace = true, features = [ "net", "rt", "rt-multi-thread", "sync"] }
 
diff --git a/proxmox-async/src/runtime.rs b/proxmox-async/src/runtime.rs
index efc1cd88..0721fd9e 100644
--- a/proxmox-async/src/runtime.rs
+++ b/proxmox-async/src/runtime.rs
@@ -33,19 +33,16 @@
 //! [openssl-bug]: https://github.com/openssl/openssl/issues/6214
 
 use std::future::Future;
-use std::sync::{Arc, Mutex, Weak};
+use std::sync::{Arc, LazyLock, Mutex, Weak};
 use std::task::{Context, Poll, Waker};
 use std::thread::{self, Thread};
 
-use lazy_static::lazy_static;
 use pin_utils::pin_mut;
 use tokio::runtime::{self, Runtime, RuntimeFlavor};
 
-lazy_static! {
-    // avoid openssl bug: https://github.com/openssl/openssl/issues/6214
-    // by dropping the runtime as early as possible
-    static ref RUNTIME: Mutex<Weak<Runtime>> = Mutex::new(Weak::new());
-}
+// avoid openssl bug: https://github.com/openssl/openssl/issues/6214
+// by dropping the runtime as early as possible
+static RUNTIME: LazyLock<Mutex<Weak<Runtime>>> = LazyLock::new(|| Mutex::new(Weak::new()));
 
 #[link(name = "crypto")]
 extern "C" {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 04/12] subscription: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 03/12] async: remove lazy_static dependency Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 05/12] rest-server: " Maximiliano Sandoval
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-subscription/Cargo.toml   | 2 +-
 proxmox-subscription/src/check.rs | 8 ++++----
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/proxmox-subscription/Cargo.toml b/proxmox-subscription/Cargo.toml
index 4ec37d4c..38fc8e22 100644
--- a/proxmox-subscription/Cargo.toml
+++ b/proxmox-subscription/Cargo.toml
@@ -6,6 +6,7 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "Proxmox subscription utilitites"
+rust-version.workspace = true
 
 exclude.workspace = true
 
@@ -13,7 +14,6 @@ exclude.workspace = true
 anyhow.workspace = true
 base64.workspace = true
 hex.workspace = true
-lazy_static.workspace = true
 openssl.workspace = true
 regex.workspace = true
 serde.workspace = true
diff --git a/proxmox-subscription/src/check.rs b/proxmox-subscription/src/check.rs
index 0ef6f046..8522bcd3 100644
--- a/proxmox-subscription/src/check.rs
+++ b/proxmox-subscription/src/check.rs
@@ -1,6 +1,7 @@
+use std::sync::LazyLock;
+
 use anyhow::{bail, format_err, Error};
 
-use lazy_static::lazy_static;
 use regex::Regex;
 use serde_json::json;
 
@@ -11,9 +12,8 @@ use crate::{
     SubscriptionInfo, SubscriptionStatus,
 };
 
-lazy_static! {
-    static ref ATTR_RE: Regex = Regex::new(r"<([^>]+)>([^<]+)</[^>]+>").unwrap();
-}
+static ATTR_RE: LazyLock<Regex> =
+    LazyLock::new(|| Regex::new(r"<([^>]+)>([^<]+)</[^>]+>").unwrap());
 
 const SHOP_URI: &str = "https://shop.proxmox.com/modules/servers/licensing/verify.php";
 
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 05/12] rest-server: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (2 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 04/12] subscription: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 06/12] time: " Maximiliano Sandoval
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-rest-server/Cargo.toml                      |  2 +-
 proxmox-rest-server/examples/minimal-rest-server.rs |  8 +++-----
 proxmox-rest-server/src/lib.rs                      | 11 +++++++----
 proxmox-rest-server/src/rest.rs                     |  7 ++-----
 proxmox-rest-server/src/worker_task.rs              |  9 +++------
 5 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/proxmox-rest-server/Cargo.toml b/proxmox-rest-server/Cargo.toml
index 3f69e550..e35cb42f 100644
--- a/proxmox-rest-server/Cargo.toml
+++ b/proxmox-rest-server/Cargo.toml
@@ -6,6 +6,7 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "REST server implementation"
+rust-version.workspace = true
 
 exclude.workspace = true
 
@@ -19,7 +20,6 @@ futures.workspace = true
 handlebars = { workspace = true, optional = true }
 http.workspace = true
 hyper = { workspace = true, features = [ "full" ] }
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/proxmox-rest-server/examples/minimal-rest-server.rs b/proxmox-rest-server/examples/minimal-rest-server.rs
index a93ef0f5..d6a5f2eb 100644
--- a/proxmox-rest-server/examples/minimal-rest-server.rs
+++ b/proxmox-rest-server/examples/minimal-rest-server.rs
@@ -1,13 +1,12 @@
 use std::collections::HashMap;
 use std::future::Future;
 use std::pin::Pin;
-use std::sync::Mutex;
+use std::sync::{LazyLock, Mutex};
 
 use anyhow::{bail, format_err, Error};
 use http::request::Parts;
 use http::HeaderMap;
 use hyper::{Body, Method, Response};
-use lazy_static::lazy_static;
 
 use proxmox_router::{
     list_subdirs_api_method, Router, RpcEnvironmentType, SubdirMap, UserInformation,
@@ -70,9 +69,8 @@ fn ping() -> Result<String, Error> {
     Ok("pong".to_string())
 }
 
-lazy_static! {
-    static ref ITEM_MAP: Mutex<HashMap<String, String>> = Mutex::new(HashMap::new());
-}
+static ITEM_MAP: LazyLock<Mutex<HashMap<String, String>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
 
 #[api]
 /// Lists all current items
diff --git a/proxmox-rest-server/src/lib.rs b/proxmox-rest-server/src/lib.rs
index 3c9e887b..43dafa91 100644
--- a/proxmox-rest-server/src/lib.rs
+++ b/proxmox-rest-server/src/lib.rs
@@ -17,6 +17,7 @@
 #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
 
 use std::fmt;
+use std::sync::LazyLock;
 
 use anyhow::{format_err, Error};
 use nix::unistd::Pid;
@@ -46,10 +47,12 @@ pub use worker_task::*;
 mod h2service;
 pub use h2service::*;
 
-lazy_static::lazy_static! {
-    static ref PID: i32 = unsafe { libc::getpid() };
-    static ref PSTART: u64 = PidStat::read_from_pid(Pid::from_raw(*PID)).unwrap().starttime;
-}
+static PID: LazyLock<i32> = LazyLock::new(|| unsafe { libc::getpid() });
+static PSTART: LazyLock<u64> = LazyLock::new(|| {
+    PidStat::read_from_pid(Pid::from_raw(*PID))
+        .unwrap()
+        .starttime
+});
 
 /// Returns the current process ID (see [libc::getpid])
 ///
diff --git a/proxmox-rest-server/src/rest.rs b/proxmox-rest-server/src/rest.rs
index fa9e043a..8b444c80 100644
--- a/proxmox-rest-server/src/rest.rs
+++ b/proxmox-rest-server/src/rest.rs
@@ -4,7 +4,7 @@ use std::hash::BuildHasher;
 use std::io;
 use std::path::{Path, PathBuf};
 use std::pin::Pin;
-use std::sync::{Arc, Mutex};
+use std::sync::{Arc, LazyLock, Mutex};
 use std::task::{Context, Poll};
 
 use anyhow::{bail, format_err, Error};
@@ -14,7 +14,6 @@ use hyper::body::HttpBody;
 use hyper::header::{self, HeaderMap};
 use hyper::http::request::Parts;
 use hyper::{Body, Request, Response, StatusCode};
-use lazy_static::lazy_static;
 use regex::Regex;
 use serde_json::Value;
 use tokio::fs::File;
@@ -289,9 +288,7 @@ fn log_response(
 }
 
 fn get_proxied_peer(headers: &HeaderMap) -> Option<std::net::SocketAddr> {
-    lazy_static! {
-        static ref RE: Regex = Regex::new(r#"for="([^"]+)""#).unwrap();
-    }
+    static RE: LazyLock<Regex> = LazyLock::new(|| Regex::new(r#"for="([^"]+)""#).unwrap());
     let forwarded = headers.get(header::FORWARDED)?.to_str().ok()?;
     let capture = RE.captures(forwarded)?;
     let rhost = capture.get(1)?.as_str();
diff --git a/proxmox-rest-server/src/worker_task.rs b/proxmox-rest-server/src/worker_task.rs
index 62e5893f..228abb7f 100644
--- a/proxmox-rest-server/src/worker_task.rs
+++ b/proxmox-rest-server/src/worker_task.rs
@@ -4,12 +4,11 @@ use std::io::{BufRead, BufReader, Read, Write};
 use std::panic::UnwindSafe;
 use std::path::PathBuf;
 use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
-use std::sync::{Arc, Mutex, OnceLock};
+use std::sync::{Arc, LazyLock, Mutex, OnceLock};
 use std::time::{Duration, SystemTime};
 
 use anyhow::{bail, format_err, Error};
 use futures::*;
-use lazy_static::lazy_static;
 use nix::fcntl::OFlag;
 use once_cell::sync::OnceCell;
 use serde::{Deserialize, Serialize};
@@ -497,10 +496,8 @@ pub fn upid_read_status(upid: &UPID) -> Result<TaskState, Error> {
     Ok(TaskState::Unknown { endtime }) // no last line with both, end-time and task-state, found.
 }
 
-lazy_static! {
-    static ref WORKER_TASK_LIST: Mutex<HashMap<usize, Arc<WorkerTask>>> =
-        Mutex::new(HashMap::new());
-}
+static WORKER_TASK_LIST: LazyLock<Mutex<HashMap<usize, Arc<WorkerTask>>>> =
+    LazyLock::new(|| Mutex::new(HashMap::new()));
 
 /// checks if the task UPID refers to a worker from this process
 fn is_local_worker(upid: &UPID) -> bool {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 06/12] time: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (3 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 05/12] rest-server: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 07/12] sys: " Maximiliano Sandoval
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-time/Cargo.toml       |  2 +-
 proxmox-time/src/time_span.rs | 94 +++++++++++++++++------------------
 2 files changed, 47 insertions(+), 49 deletions(-)

diff --git a/proxmox-time/Cargo.toml b/proxmox-time/Cargo.toml
index 17282507..d863fa0c 100644
--- a/proxmox-time/Cargo.toml
+++ b/proxmox-time/Cargo.toml
@@ -6,13 +6,13 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "time utilities and TmEditor"
+rust-version.workspace = true
 
 exclude.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 bitflags.workspace = true
-lazy_static.workspace = true
 nom = "7"
 
 [target.'cfg(not(target_arch="wasm32"))'.dependencies]
diff --git a/proxmox-time/src/time_span.rs b/proxmox-time/src/time_span.rs
index e580c3d6..2ccdf08b 100644
--- a/proxmox-time/src/time_span.rs
+++ b/proxmox-time/src/time_span.rs
@@ -1,79 +1,77 @@
 use std::collections::HashMap;
+use std::sync::LazyLock;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 use nom::{bytes::complete::take_while1, character::complete::space0, combinator::opt};
 
 use crate::parse_helpers::{parse_complete_line, parse_error, parse_u64, IResult};
 
-lazy_static! {
-    static ref TIME_SPAN_UNITS: HashMap<&'static str, f64> = {
-        let mut map = HashMap::new();
+static TIME_SPAN_UNITS: LazyLock<HashMap<&'static str, f64>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
 
-        let second = 1.0;
+    let second = 1.0;
 
-        map.insert("seconds", second);
-        map.insert("second", second);
-        map.insert("sec", second);
-        map.insert("s", second);
+    map.insert("seconds", second);
+    map.insert("second", second);
+    map.insert("sec", second);
+    map.insert("s", second);
 
-        let msec = second / 1000.0;
+    let msec = second / 1000.0;
 
-        map.insert("msec", msec);
-        map.insert("ms", msec);
+    map.insert("msec", msec);
+    map.insert("ms", msec);
 
-        let usec = msec / 1000.0;
+    let usec = msec / 1000.0;
 
-        map.insert("usec", usec);
-        map.insert("us", usec);
-        map.insert("µs", usec);
+    map.insert("usec", usec);
+    map.insert("us", usec);
+    map.insert("µs", usec);
 
-        let nsec = usec / 1000.0;
+    let nsec = usec / 1000.0;
 
-        map.insert("nsec", nsec);
-        map.insert("ns", nsec);
+    map.insert("nsec", nsec);
+    map.insert("ns", nsec);
 
-        let minute = second * 60.0;
+    let minute = second * 60.0;
 
-        map.insert("minutes", minute);
-        map.insert("minute", minute);
-        map.insert("min", minute);
-        map.insert("m", minute);
+    map.insert("minutes", minute);
+    map.insert("minute", minute);
+    map.insert("min", minute);
+    map.insert("m", minute);
 
-        let hour = minute * 60.0;
+    let hour = minute * 60.0;
 
-        map.insert("hours", hour);
-        map.insert("hour", hour);
-        map.insert("hr", hour);
-        map.insert("h", hour);
+    map.insert("hours", hour);
+    map.insert("hour", hour);
+    map.insert("hr", hour);
+    map.insert("h", hour);
 
-        let day = hour * 24.0;
+    let day = hour * 24.0;
 
-        map.insert("days", day);
-        map.insert("day", day);
-        map.insert("d", day);
+    map.insert("days", day);
+    map.insert("day", day);
+    map.insert("d", day);
 
-        let week = day * 7.0;
+    let week = day * 7.0;
 
-        map.insert("weeks", week);
-        map.insert("week", week);
-        map.insert("w", week);
+    map.insert("weeks", week);
+    map.insert("week", week);
+    map.insert("w", week);
 
-        let month = 30.44 * day;
+    let month = 30.44 * day;
 
-        map.insert("months", month);
-        map.insert("month", month);
-        map.insert("M", month);
+    map.insert("months", month);
+    map.insert("month", month);
+    map.insert("M", month);
 
-        let year = 365.25 * day;
+    let year = 365.25 * day;
 
-        map.insert("years", year);
-        map.insert("year", year);
-        map.insert("y", year);
+    map.insert("years", year);
+    map.insert("year", year);
+    map.insert("y", year);
 
-        map
-    };
-}
+    map
+});
 
 /// A time spans defines a time duration
 #[derive(Default, Clone, Debug)]
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 07/12] sys: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (4 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 06/12] time: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 08/12] network-api: " Maximiliano Sandoval
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-sys/Cargo.toml              |  2 +-
 proxmox-sys/src/lib.rs              | 29 ++++++++++++++---------------
 proxmox-sys/src/linux/procfs/mod.rs | 13 ++++---------
 3 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/proxmox-sys/Cargo.toml b/proxmox-sys/Cargo.toml
index 4022228c..c5d2bd87 100644
--- a/proxmox-sys/Cargo.toml
+++ b/proxmox-sys/Cargo.toml
@@ -6,13 +6,13 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "System tools (using nix)."
+rust-version.workspace = true
 
 exclude.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 base64.workspace = true
-lazy_static.workspace = true
 libc.workspace = true
 log.workspace = true
 nix.workspace = true
diff --git a/proxmox-sys/src/lib.rs b/proxmox-sys/src/lib.rs
index a16b46e3..c75cd69f 100644
--- a/proxmox-sys/src/lib.rs
+++ b/proxmox-sys/src/lib.rs
@@ -2,6 +2,7 @@
 
 use std::os::fd::{FromRawFd, OwnedFd};
 use std::os::unix::ffi::OsStrExt;
+use std::sync::LazyLock;
 
 pub mod boot_mode;
 pub mod command;
@@ -20,21 +21,19 @@ pub mod systemd;
 
 /// Returns the hosts node name (UTS node name)
 pub fn nodename() -> &'static str {
-    lazy_static::lazy_static! {
-        static ref NODENAME: String = {
-            std::str::from_utf8(
-                nix::sys::utsname::uname()
-                    .expect("failed to get nodename")
-                    .nodename()
-                    .as_bytes(),
-            )
-            .expect("non utf-8 nodename not supported")
-            .split('.')
-            .next()
-            .unwrap()
-            .to_owned()
-        };
-    }
+    static NODENAME: LazyLock<String> = LazyLock::new(|| {
+        std::str::from_utf8(
+            nix::sys::utsname::uname()
+                .expect("failed to get nodename")
+                .nodename()
+                .as_bytes(),
+        )
+        .expect("non utf-8 nodename not supported")
+        .split('.')
+        .next()
+        .unwrap()
+        .to_owned()
+    });
 
     &NODENAME
 }
diff --git a/proxmox-sys/src/linux/procfs/mod.rs b/proxmox-sys/src/linux/procfs/mod.rs
index 6c436c74..0875fcf8 100644
--- a/proxmox-sys/src/linux/procfs/mod.rs
+++ b/proxmox-sys/src/linux/procfs/mod.rs
@@ -5,11 +5,10 @@ use std::fs::OpenOptions;
 use std::io::{BufRead, BufReader};
 use std::net::{Ipv4Addr, Ipv6Addr};
 use std::str::FromStr;
-use std::sync::RwLock;
+use std::sync::{LazyLock, RwLock};
 use std::time::Instant;
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use nix::unistd::Pid;
 use serde::Serialize;
 
@@ -27,9 +26,7 @@ pub fn sysconf(name: i32) -> i64 {
     unsafe { sysconf(name) }
 }
 
-lazy_static! {
-    pub static ref CLOCK_TICKS: f64 = sysconf(libc::_SC_CLK_TCK) as f64;
-}
+pub static CLOCK_TICKS: LazyLock<f64> = LazyLock::new(|| sysconf(libc::_SC_CLK_TCK) as f64);
 
 /// Selected contents of the `/proc/PID/stat` file.
 pub struct PidStat {
@@ -223,10 +220,8 @@ pub struct ProcFsStat {
     pub iowait_percent: f64,
 }
 
-lazy_static! {
-    static ref PROC_LAST_STAT: RwLock<(ProcFsStat, Instant, bool)> =
-        RwLock::new((ProcFsStat::default(), Instant::now(), true));
-}
+static PROC_LAST_STAT: LazyLock<RwLock<(ProcFsStat, Instant, bool)>> =
+    LazyLock::new(|| RwLock::new((ProcFsStat::default(), Instant::now(), true)));
 
 /// reads `/proc/stat`. For now only total host CPU usage is handled as the
 /// other metrics are not really interesting
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 08/12] network-api: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (5 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 07/12] sys: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 09/12] auth-api: " Maximiliano Sandoval
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-network-api/Cargo.toml           |  2 +-
 proxmox-network-api/src/api_types.rs     | 12 ++---
 proxmox-network-api/src/config/helper.rs | 35 ++++++-------
 proxmox-network-api/src/config/lexer.rs  | 67 +++++++++++-------------
 proxmox-network-api/src/config/mod.rs    | 17 +++---
 proxmox-network-api/src/config/parser.rs |  7 ++-
 6 files changed, 65 insertions(+), 75 deletions(-)

diff --git a/proxmox-network-api/Cargo.toml b/proxmox-network-api/Cargo.toml
index 8f81b3bd..11fd9cb8 100644
--- a/proxmox-network-api/Cargo.toml
+++ b/proxmox-network-api/Cargo.toml
@@ -7,11 +7,11 @@ license.workspace = true
 repository.workspace = true
 exclude.workspace = true
 description = "Network Management API implementation"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 const_format.workspace = true
-lazy_static.workspace = true
 regex.workspace = true
 
 serde = { workspace = true, features = ["derive"] }
diff --git a/proxmox-network-api/src/api_types.rs b/proxmox-network-api/src/api_types.rs
index ba1615e0..9f12b029 100644
--- a/proxmox-network-api/src/api_types.rs
+++ b/proxmox-network-api/src/api_types.rs
@@ -1,9 +1,9 @@
 use std::fmt;
+use std::sync::LazyLock;
 
 use anyhow::{bail, Error};
 use serde::{Deserialize, Serialize};
 
-use lazy_static::lazy_static;
 use regex::Regex;
 
 use proxmox_schema::api;
@@ -15,11 +15,11 @@ use proxmox_schema::ArraySchema;
 use proxmox_schema::Schema;
 use proxmox_schema::StringSchema;
 
-lazy_static! {
-    pub static ref PHYSICAL_NIC_REGEX: Regex = Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap();
-    pub static ref VLAN_INTERFACE_REGEX: Regex =
-        Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap();
-}
+pub static PHYSICAL_NIC_REGEX: LazyLock<Regex> =
+    LazyLock::new(|| Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap());
+pub static VLAN_INTERFACE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
+    Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap()
+});
 
 pub const NETWORK_INTERFACE_FORMAT: ApiStringFormat = ApiStringFormat::Pattern(&SAFE_ID_REGEX);
 
diff --git a/proxmox-network-api/src/config/helper.rs b/proxmox-network-api/src/config/helper.rs
index 00464384..9cc23eef 100644
--- a/proxmox-network-api/src/config/helper.rs
+++ b/proxmox-network-api/src/config/helper.rs
@@ -2,10 +2,10 @@ use std::collections::HashMap;
 use std::os::unix::io::{AsRawFd, FromRawFd, OwnedFd};
 use std::path::Path;
 use std::process::Command;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
 use const_format::concatcp;
-use lazy_static::lazy_static;
 use nix::ioctl_read_bad;
 use nix::sys::socket::{socket, AddressFamily, SockFlag, SockType};
 use regex::Regex;
@@ -49,16 +49,14 @@ pub static IPV4_REVERSE_MASK: &[&str] = &[
     "255.255.255.255",
 ];
 
-lazy_static! {
-    pub static ref IPV4_MASK_HASH_LOCALNET: HashMap<&'static str, u8> = {
-        let mut map = HashMap::new();
-        #[allow(clippy::needless_range_loop)]
-        for i in 0..IPV4_REVERSE_MASK.len() {
-            map.insert(IPV4_REVERSE_MASK[i], i as u8);
-        }
-        map
-    };
-}
+pub static IPV4_MASK_HASH_LOCALNET: LazyLock<HashMap<&'static str, u8>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
+    #[allow(clippy::needless_range_loop)]
+    for i in 0..IPV4_REVERSE_MASK.len() {
+        map.insert(IPV4_REVERSE_MASK[i], i as u8);
+    }
+    map
+});
 
 pub fn parse_cidr(cidr: &str) -> Result<(String, u8, bool), Error> {
     let (address, mask, is_v6) = parse_address_or_cidr(cidr)?;
@@ -93,12 +91,10 @@ pub(crate) fn check_netmask(mask: u8, is_v6: bool) -> Result<(), Error> {
 pub(crate) fn parse_address_or_cidr(cidr: &str) -> Result<(String, Option<u8>, bool), Error> {
     // NOTE: This is NOT the same regex as in proxmox-schema as this one has capture groups for
     // the addresses vs cidr portions!
-    lazy_static! {
-        pub static ref CIDR_V4_REGEX: Regex =
-            Regex::new(concatcp!(r"^(", IPV4RE_STR, r")(?:/(\d{1,2}))?$")).unwrap();
-        pub static ref CIDR_V6_REGEX: Regex =
-            Regex::new(concatcp!(r"^(", IPV6RE_STR, r")(?:/(\d{1,3}))?$")).unwrap();
-    }
+    pub static CIDR_V4_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^(", IPV4RE_STR, r")(?:/(\d{1,2}))?$")).unwrap());
+    pub static CIDR_V6_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(concatcp!(r"^(", IPV6RE_STR, r")(?:/(\d{1,3}))?$")).unwrap());
 
     if let Some(caps) = CIDR_V4_REGEX.captures(cidr) {
         let address = &caps[1];
@@ -134,9 +130,8 @@ pub(crate) fn get_network_interfaces() -> Result<HashMap<String, bool>, Error> {
 
     ioctl_read_bad!(get_interface_flags, libc::SIOCGIFFLAGS, ifreq);
 
-    lazy_static! {
-        static ref IFACE_LINE_REGEX: Regex = Regex::new(r"^\s*([^:\s]+):").unwrap();
-    }
+    static IFACE_LINE_REGEX: LazyLock<Regex> =
+        LazyLock::new(|| Regex::new(r"^\s*([^:\s]+):").unwrap());
     let raw = std::fs::read_to_string(PROC_NET_DEV)
         .map_err(|err| format_err!("unable to read {} - {}", PROC_NET_DEV, err))?;
 
diff --git a/proxmox-network-api/src/config/lexer.rs b/proxmox-network-api/src/config/lexer.rs
index d0b7d8cd..6a20f009 100644
--- a/proxmox-network-api/src/config/lexer.rs
+++ b/proxmox-network-api/src/config/lexer.rs
@@ -1,8 +1,7 @@
 use std::collections::{HashMap, VecDeque};
 use std::io::BufRead;
 use std::iter::Iterator;
-
-use lazy_static::lazy_static;
+use std::sync::LazyLock;
 
 #[derive(Debug, Copy, Clone, Eq, PartialEq)]
 pub enum Token {
@@ -33,39 +32,37 @@ pub enum Token {
     EOF,
 }
 
-lazy_static! {
-    static ref KEYWORDS: HashMap<&'static str, Token> = {
-        let mut map = HashMap::new();
-        map.insert("address", Token::Address);
-        map.insert("auto", Token::Auto);
-        map.insert("dhcp", Token::DHCP);
-        map.insert("gateway", Token::Gateway);
-        map.insert("inet", Token::Inet);
-        map.insert("inet6", Token::Inet6);
-        map.insert("iface", Token::Iface);
-        map.insert("loopback", Token::Loopback);
-        map.insert("manual", Token::Manual);
-        map.insert("netmask", Token::Netmask);
-        map.insert("static", Token::Static);
-        map.insert("mtu", Token::MTU);
-        map.insert("bridge-ports", Token::BridgePorts);
-        map.insert("bridge_ports", Token::BridgePorts);
-        map.insert("bridge-vlan-aware", Token::BridgeVlanAware);
-        map.insert("bridge_vlan_aware", Token::BridgeVlanAware);
-        map.insert("vlan-id", Token::VlanId);
-        map.insert("vlan_id", Token::VlanId);
-        map.insert("vlan-raw-device", Token::VlanRawDevice);
-        map.insert("vlan_raw_device", Token::VlanRawDevice);
-        map.insert("bond-slaves", Token::BondSlaves);
-        map.insert("bond_slaves", Token::BondSlaves);
-        map.insert("bond-mode", Token::BondMode);
-        map.insert("bond-primary", Token::BondPrimary);
-        map.insert("bond_primary", Token::BondPrimary);
-        map.insert("bond_xmit_hash_policy", Token::BondXmitHashPolicy);
-        map.insert("bond-xmit-hash-policy", Token::BondXmitHashPolicy);
-        map
-    };
-}
+static KEYWORDS: LazyLock<HashMap<&'static str, Token>> = LazyLock::new(|| {
+    let mut map = HashMap::new();
+    map.insert("address", Token::Address);
+    map.insert("auto", Token::Auto);
+    map.insert("dhcp", Token::DHCP);
+    map.insert("gateway", Token::Gateway);
+    map.insert("inet", Token::Inet);
+    map.insert("inet6", Token::Inet6);
+    map.insert("iface", Token::Iface);
+    map.insert("loopback", Token::Loopback);
+    map.insert("manual", Token::Manual);
+    map.insert("netmask", Token::Netmask);
+    map.insert("static", Token::Static);
+    map.insert("mtu", Token::MTU);
+    map.insert("bridge-ports", Token::BridgePorts);
+    map.insert("bridge_ports", Token::BridgePorts);
+    map.insert("bridge-vlan-aware", Token::BridgeVlanAware);
+    map.insert("bridge_vlan_aware", Token::BridgeVlanAware);
+    map.insert("vlan-id", Token::VlanId);
+    map.insert("vlan_id", Token::VlanId);
+    map.insert("vlan-raw-device", Token::VlanRawDevice);
+    map.insert("vlan_raw_device", Token::VlanRawDevice);
+    map.insert("bond-slaves", Token::BondSlaves);
+    map.insert("bond_slaves", Token::BondSlaves);
+    map.insert("bond-mode", Token::BondMode);
+    map.insert("bond-primary", Token::BondPrimary);
+    map.insert("bond_primary", Token::BondPrimary);
+    map.insert("bond_xmit_hash_policy", Token::BondXmitHashPolicy);
+    map.insert("bond-xmit-hash-policy", Token::BondXmitHashPolicy);
+    map
+});
 
 pub struct Lexer<R> {
     input: R,
diff --git a/proxmox-network-api/src/config/mod.rs b/proxmox-network-api/src/config/mod.rs
index d9efeff9..054f53c8 100644
--- a/proxmox-network-api/src/config/mod.rs
+++ b/proxmox-network-api/src/config/mod.rs
@@ -6,9 +6,9 @@ pub use helper::{assert_ifupdown2_installed, network_reload, parse_cidr};
 
 use std::collections::{BTreeMap, HashMap, HashSet};
 use std::io::Write;
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use regex::Regex;
 use serde::de::{value, Deserialize, IntoDeserializer};
 
@@ -23,11 +23,11 @@ use parser::NetworkParser;
 use proxmox_config_digest::ConfigDigest;
 use proxmox_product_config::{open_api_lockfile, replace_system_config, ApiLockGuard};
 
-lazy_static! {
-    static ref PHYSICAL_NIC_REGEX: Regex = Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap();
-    static ref VLAN_INTERFACE_REGEX: Regex =
-        Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap();
-}
+static PHYSICAL_NIC_REGEX: LazyLock<Regex> =
+    LazyLock::new(|| Regex::new(r"^(?:eth\d+|en[^:.]+|ib\d+)$").unwrap());
+static VLAN_INTERFACE_REGEX: LazyLock<Regex> = LazyLock::new(|| {
+    Regex::new(r"^(?P<vlan_raw_device>\S+)\.(?P<vlan_id>\d+)|vlan(?P<vlan_id2>\d+)$").unwrap()
+});
 
 pub fn is_physical_nic(iface: &str) -> bool {
     PHYSICAL_NIC_REGEX.is_match(iface)
@@ -409,9 +409,8 @@ impl NetworkConfig {
 
     /// Check if bridge ports exists
     fn check_bridge_ports(&self) -> Result<(), Error> {
-        lazy_static! {
-            static ref VLAN_INTERFACE_REGEX: Regex = Regex::new(r"^(\S+)\.(\d+)$").unwrap();
-        }
+        static VLAN_INTERFACE_REGEX: LazyLock<Regex> =
+            LazyLock::new(|| Regex::new(r"^(\S+)\.(\d+)$").unwrap());
 
         for (iface, interface) in self.interfaces.iter() {
             if let Some(ports) = &interface.bridge_ports {
diff --git a/proxmox-network-api/src/config/parser.rs b/proxmox-network-api/src/config/parser.rs
index 2d20b9e4..d05a67b0 100644
--- a/proxmox-network-api/src/config/parser.rs
+++ b/proxmox-network-api/src/config/parser.rs
@@ -3,9 +3,9 @@ use crate::VLAN_INTERFACE_REGEX;
 use std::collections::{HashMap, HashSet};
 use std::io::BufRead;
 use std::iter::{Iterator, Peekable};
+use std::sync::LazyLock;
 
 use anyhow::{bail, format_err, Error};
-use lazy_static::lazy_static;
 use regex::Regex;
 use serde::de::{value, Deserialize, IntoDeserializer};
 
@@ -551,9 +551,8 @@ impl<R: BufRead> NetworkParser<R> {
             }
         }
 
-        lazy_static! {
-            static ref INTERFACE_ALIAS_REGEX: Regex = Regex::new(r"^\S+:\d+$").unwrap();
-        }
+        static INTERFACE_ALIAS_REGEX: LazyLock<Regex> =
+            LazyLock::new(|| Regex::new(r"^\S+:\d+$").unwrap());
 
         if let Some(existing_interfaces) = existing_interfaces {
             for (iface, active) in existing_interfaces.iter() {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 09/12] auth-api: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (6 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 08/12] network-api: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 10/12] acme-api: " Maximiliano Sandoval
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@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@pam".to_string(), 4);
-}
+pub static ROOT_USERID: LazyLock<Userid> = LazyLock::new(|| Userid::new("root@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@pam".to_string(), 4));
-}
+pub static ROOT_AUTHID: LazyLock<Authid> =
+    LazyLock::new(|| Authid::from(Userid::new("root@pam".to_string(), 4)));
 
 impl From<Userid> for Authid {
     fn from(parts: Userid) -> Self {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 10/12] acme-api: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (7 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 09/12] auth-api: " Maximiliano Sandoval
@ 2024-08-14  7:19 ` Maximiliano Sandoval
  2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 11/12] schema: " Maximiliano Sandoval
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:19 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-acme-api/Cargo.toml               |  3 +--
 proxmox-acme-api/src/challenge_schemas.rs | 10 +++-------
 proxmox-acme-api/src/plugin_config.rs     |  7 +++----
 3 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/proxmox-acme-api/Cargo.toml b/proxmox-acme-api/Cargo.toml
index 13ace495..d00d8ab7 100644
--- a/proxmox-acme-api/Cargo.toml
+++ b/proxmox-acme-api/Cargo.toml
@@ -7,6 +7,7 @@ license.workspace = true
 repository.workspace = true
 exclude.workspace = true
 description = "ACME API implementation"
+rust-version.workspace = true
 
 [dependencies]
 anyhow.workspace = true
@@ -15,7 +16,6 @@ futures = { workspace = true, optional = true }
 hex = { workspace = true, optional = true }
 http = { workspace = true, optional = true }
 hyper = { workspace = true, optional = true }
-lazy_static = { workspace = true, optional = true }
 log = { workspace = true, optional = true }
 nix = { workspace = true, optional = true }
 serde = { workspace = true, features = ["derive"] }
@@ -48,7 +48,6 @@ impl = [
     "dep:hex",
     "dep:http",
     "dep:hyper",
-    "dep:lazy_static",
     "dep:libc",
     "dep:log",
     "dep:nix",
diff --git a/proxmox-acme-api/src/challenge_schemas.rs b/proxmox-acme-api/src/challenge_schemas.rs
index 6e1217c8..40a6a6af 100644
--- a/proxmox-acme-api/src/challenge_schemas.rs
+++ b/proxmox-acme-api/src/challenge_schemas.rs
@@ -2,12 +2,10 @@
 //!
 //! Those schemas are provided by debian  package "libproxmox-acme-plugins".
 
-use std::sync::Arc;
-use std::sync::Mutex;
+use std::sync::{Arc, LazyLock, Mutex};
 use std::time::SystemTime;
 
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde::Serialize;
 use serde_json::Value;
 
@@ -51,10 +49,8 @@ fn load_dns_challenge_schema() -> Result<Vec<AcmeChallengeSchema>, Error> {
 }
 
 pub fn get_cached_challenge_schemas() -> Result<ChallengeSchemaWrapper, Error> {
-    lazy_static! {
-        static ref CACHE: Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>> =
-            Mutex::new(None);
-    }
+    static CACHE: LazyLock<Mutex<Option<(Arc<Vec<AcmeChallengeSchema>>, SystemTime)>>> =
+        LazyLock::new(|| Mutex::new(None));
 
     // the actual loading code
     let mut last = CACHE.lock().unwrap();
diff --git a/proxmox-acme-api/src/plugin_config.rs b/proxmox-acme-api/src/plugin_config.rs
index d75bea59..b7ed7594 100644
--- a/proxmox-acme-api/src/plugin_config.rs
+++ b/proxmox-acme-api/src/plugin_config.rs
@@ -1,7 +1,8 @@
 //! ACME plugin configuration helpers (SectionConfig implementation)
 
+use std::sync::LazyLock;
+
 use anyhow::Error;
-use lazy_static::lazy_static;
 use serde_json::Value;
 
 use proxmox_config_digest::ConfigDigest;
@@ -11,9 +12,7 @@ use proxmox_section_config::{SectionConfig, SectionConfigData, SectionConfigPlug
 
 use crate::types::{DnsPlugin, StandalonePlugin, PLUGIN_ID_SCHEMA};
 
-lazy_static! {
-    static ref CONFIG: SectionConfig = init();
-}
+static CONFIG: LazyLock<SectionConfig> = LazyLock::new(init);
 
 impl DnsPlugin {
     pub fn decode_data(&self, output: &mut Vec<u8>) -> Result<(), Error> {
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 11/12] schema: remove lazy_static dependency
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (8 preceding siblings ...)
  2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 10/12] acme-api: " Maximiliano Sandoval
@ 2024-08-14  7:20 ` Maximiliano Sandoval
  2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 12/12] cargo: remove lazy_static dependency on workspace Maximiliano Sandoval
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:20 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 proxmox-schema/Cargo.toml         | 2 +-
 proxmox-schema/src/const_regex.rs | 6 ++----
 proxmox-schema/src/lib.rs         | 8 --------
 3 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/proxmox-schema/Cargo.toml b/proxmox-schema/Cargo.toml
index f3aea3e1..ac4839e9 100644
--- a/proxmox-schema/Cargo.toml
+++ b/proxmox-schema/Cargo.toml
@@ -6,13 +6,13 @@ edition.workspace = true
 license.workspace = true
 repository.workspace = true
 description = "proxmox api schema and validation"
+rust-version.workspace = true
 
 exclude.workspace = true
 
 [dependencies]
 anyhow.workspace = true
 const_format = { workspace = true, optional = true }
-lazy_static.workspace = true
 regex.workspace = true
 serde.workspace = true
 serde_json.workspace = true
diff --git a/proxmox-schema/src/const_regex.rs b/proxmox-schema/src/const_regex.rs
index 3a5c2dab..8ddc41ab 100644
--- a/proxmox-schema/src/const_regex.rs
+++ b/proxmox-schema/src/const_regex.rs
@@ -5,7 +5,7 @@ use std::fmt;
 /// The current Regex::new() function is not `const_fn`. Unless that
 /// works, we use `ConstRegexPattern` to represent static regular
 /// expressions. Please use the `const_regex` macro to generate
-/// instances of this type (uses lazy_static).
+/// instances of this type.
 pub struct ConstRegexPattern {
     /// This is only used for documentation and debugging
     pub regex_string: &'static str,
@@ -47,9 +47,7 @@ macro_rules! const_regex {
             $crate::ConstRegexPattern {
                 regex_string: $regex,
                 regex_obj: (|| ->   &'static ::regex::Regex {
-                    $crate::semver_exempt::lazy_static! {
-                        static ref SCHEMA: ::regex::Regex = ::regex::Regex::new($regex).unwrap();
-                    }
+                    static SCHEMA: std::sync::LazyLock<::regex::Regex> = std::sync::LazyLock::new(|| ::regex::Regex::new($regex).unwrap());
                     &SCHEMA
                 })
             };
diff --git a/proxmox-schema/src/lib.rs b/proxmox-schema/src/lib.rs
index c91b5fd6..161f53ce 100644
--- a/proxmox-schema/src/lib.rs
+++ b/proxmox-schema/src/lib.rs
@@ -29,13 +29,5 @@ pub use schema::*;
 
 pub mod upid;
 
-// const_regex uses lazy_static, but we otherwise don't need it, and don't want to force users to
-// have to write it out in their Cargo.toml as dependency, so we add a hidden re-export here which
-// is semver-exempt!
-#[doc(hidden)]
-pub mod semver_exempt {
-    pub use lazy_static::lazy_static;
-}
-
 #[cfg(feature = "api-types")]
 pub mod api_types;
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] [PATCH proxmox v2 12/12] cargo: remove lazy_static dependency on workspace
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (9 preceding siblings ...)
  2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 11/12] schema: " Maximiliano Sandoval
@ 2024-08-14  7:20 ` Maximiliano Sandoval
  2024-08-14  8:51 ` [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Wolfgang Bumiller
  2024-08-14 10:04 ` [pbs-devel] applied-series: " Wolfgang Bumiller
  12 siblings, 0 replies; 14+ messages in thread
From: Maximiliano Sandoval @ 2024-08-14  7:20 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 Cargo.toml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Cargo.toml b/Cargo.toml
index 71f25b45..6360db1f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -83,7 +83,6 @@ handlebars = "3.0"
 hex = "0.4"
 http = "0.2"
 hyper = "0.14.5"
-lazy_static = "1.4"
 ldap3 = { version = "0.11", default-features = false }
 lettre = "0.11.1"
 libc = "0.2.107"
-- 
2.39.2



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (10 preceding siblings ...)
  2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 12/12] cargo: remove lazy_static dependency on workspace Maximiliano Sandoval
@ 2024-08-14  8:51 ` Wolfgang Bumiller
  2024-08-14 10:04 ` [pbs-devel] applied-series: " Wolfgang Bumiller
  12 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Bumiller @ 2024-08-14  8:51 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: pbs-devel

so if all our code still builds with it I'm inclined to only do minor
bumps despite some of these technically being a public API break - but
LazyLock implements `Deref` and thus its API surface covers everything
I'd consider to be lazy_static's *intended* API surface. Relying on
technical details on how lazy_static works (an additional type for each
static...) is not an okay thing ;-)


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [pbs-devel] applied-series: [PATCH proxmox v2 01/12] cargo: set msrv to 1.80
  2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
                   ` (11 preceding siblings ...)
  2024-08-14  8:51 ` [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Wolfgang Bumiller
@ 2024-08-14 10:04 ` Wolfgang Bumiller
  12 siblings, 0 replies; 14+ messages in thread
From: Wolfgang Bumiller @ 2024-08-14 10:04 UTC (permalink / raw)
  To: Maximiliano Sandoval; +Cc: pbs-devel

applied series, thanks


_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-08-14 10:05 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-14  7:19 [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 03/12] async: remove lazy_static dependency Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 04/12] subscription: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 05/12] rest-server: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 06/12] time: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 07/12] sys: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 08/12] network-api: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 09/12] auth-api: " Maximiliano Sandoval
2024-08-14  7:19 ` [pbs-devel] [PATCH proxmox v2 10/12] acme-api: " Maximiliano Sandoval
2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 11/12] schema: " Maximiliano Sandoval
2024-08-14  7:20 ` [pbs-devel] [PATCH proxmox v2 12/12] cargo: remove lazy_static dependency on workspace Maximiliano Sandoval
2024-08-14  8:51 ` [pbs-devel] [PATCH proxmox v2 01/12] cargo: set msrv to 1.80 Wolfgang Bumiller
2024-08-14 10:04 ` [pbs-devel] applied-series: " Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal