From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 10/12] acme-api: remove lazy_static dependency
Date: Tue, 13 Aug 2024 12:57:07 +0200 [thread overview]
Message-ID: <20240813105709.320119-10-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20240813105709.320119-1-m.sandoval@proxmox.com>
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
proxmox-acme-api/Cargo.toml | 3 +--
proxmox-acme-api/debian/control | 1 -
proxmox-acme-api/src/challenge_schemas.rs | 10 +++-------
proxmox-acme-api/src/plugin_config.rs | 7 +++----
4 files changed, 7 insertions(+), 14 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/debian/control b/proxmox-acme-api/debian/control
index fb859d81..81489890 100644
--- a/proxmox-acme-api/debian/control
+++ b/proxmox-acme-api/debian/control
@@ -63,7 +63,6 @@ Depends:
librust-hex-0.4+default-dev,
librust-http-0.2+default-dev,
librust-hyper-0.14+default-dev (>= 0.14.5-~~),
- librust-lazy-static-1+default-dev (>= 1.4-~~),
librust-libc-0.2+default-dev (>= 0.2.107-~~),
librust-log-0.4+default-dev (>= 0.4.17-~~),
librust-nix-0.26+default-dev (>= 0.26.1-~~),
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
next prev parent reply other threads:[~2024-08-13 10:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-13 10:56 [pbs-devel] [PATCH proxmox 01/12] cargo: set msrv to 1.80 Maximiliano Sandoval
2024-08-13 10:56 ` [pbs-devel] [PATCH proxmox 02/12] dns-api: remove lazy-static dependency Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 03/12] async: remove lazy_static dependency Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 04/12] subscription: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 05/12] rest-server: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 06/12] time: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 07/12] sys: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 08/12] network-api: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 09/12] auth-api: " Maximiliano Sandoval
2024-08-13 10:57 ` Maximiliano Sandoval [this message]
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 11/12] schema: " Maximiliano Sandoval
2024-08-13 10:57 ` [pbs-devel] [PATCH proxmox 12/12] cargo: remove lazy_static dependency on workspace Maximiliano Sandoval
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=20240813105709.320119-10-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