From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox v2 02/12] dns-api: remove lazy-static dependency
Date: Wed, 14 Aug 2024 09:19:51 +0200 [thread overview]
Message-ID: <20240814072001.53422-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240814072001.53422-1-m.sandoval@proxmox.com>
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
next prev parent reply other threads:[~2024-08-14 7:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240814072001.53422-2-m.sandoval@proxmox.com \
--to=m.sandoval@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox