[pbs-devel] [PATCH proxmox 02/12] dns-api: remove lazy-static dependency
Maximiliano Sandoval
m.sandoval at proxmox.com
Tue Aug 13 12:56:59 CEST 2024
Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
proxmox-dns-api/Cargo.toml | 2 +-
proxmox-dns-api/debian/control | 2 --
proxmox-dns-api/src/resolv_conf.rs | 17 ++++++-----------
3 files changed, 7 insertions(+), 14 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/debian/control b/proxmox-dns-api/debian/control
index e3923623..e1c32dcf 100644
--- a/proxmox-dns-api/debian/control
+++ b/proxmox-dns-api/debian/control
@@ -8,7 +8,6 @@ Build-Depends: debhelper (>= 12),
libstd-rust-dev <!nocheck>,
librust-anyhow-1+default-dev <!nocheck>,
librust-const-format-0.2+default-dev <!nocheck>,
- librust-lazy-static-1+default-dev (>= 1.4-~~) <!nocheck>,
librust-proxmox-config-digest-0.1+default-dev <!nocheck>,
librust-proxmox-schema-3+api-macro-dev (>= 3.1.1-~~) <!nocheck>,
librust-proxmox-schema-3+api-types-dev (>= 3.1.1-~~) <!nocheck>,
@@ -31,7 +30,6 @@ Depends:
librust-anyhow-1+default-dev,
librust-const-format-0.2+default-dev,
librust-lazy-static-1+default-dev (>= 1.4-~~),
- librust-proxmox-config-digest-0.1+default-dev,
librust-proxmox-schema-3+api-macro-dev (>= 3.1.1-~~),
librust-proxmox-schema-3+api-types-dev (>= 3.1.1-~~),
librust-proxmox-schema-3+default-dev (>= 3.1.1-~~),
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
More information about the pbs-devel
mailing list