Skip to content

Commit c39b0a6

Browse files
authored
feat: Reduce dependencies, especially with --no-default-features (#7)
* feat: Move unused dependencies to optional * chore: Remove needless `once_cell` dependency * `cargo make format`
1 parent 5195ad6 commit c39b0a6

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,32 @@ unused-async = "warn"
2828

2929
[dependencies]
3030
erased_set = "0.8"
31-
http-body-util = "0.1.0"
32-
hyper = { version = "1", features = ["server", "http1"] }
33-
hyper-util = { version = "0.1.1", features = ["tokio"] }
34-
once_cell = "1.17.0"
35-
prometheus-client = { version = "0.22", optional = true }
36-
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"] }
3731
serde = { version = "1", features = ["derive"] }
3832
struct_iterable = "0.1"
3933
thiserror = "2.0.6"
40-
tokio = { version = "1", features = ["rt", "net", "fs"]}
4134
tracing = "0.1"
4235

36+
# metrics feature
37+
http-body-util = { version = "0.1.0", optional = true }
38+
hyper = { version = "1", features = ["server", "http1"], optional = true }
39+
hyper-util = { version = "0.1.1", features = ["tokio"], optional = true }
40+
prometheus-client = { version = "0.22", optional = true }
41+
reqwest = { version = "0.12", default-features = false, features = ["json", "rustls-tls"], optional = true }
42+
tokio = { version = "1", features = ["rt", "net", "fs"], optional = true }
43+
4344
[dev-dependencies]
4445
tokio = { version = "1", features = ["io-util", "sync", "rt", "net", "fs", "macros", "time", "test-util"] }
4546

4647
[features]
4748
default = ["metrics"]
48-
metrics = ["prometheus-client"]
49+
metrics = [
50+
"dep:http-body-util",
51+
"dep:hyper",
52+
"dep:hyper-util",
53+
"dep:prometheus-client",
54+
"dep:reqwest",
55+
"dep:tokio",
56+
]
4957

5058
[package.metadata.docs.rs]
5159
all-features = true

src/core.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
use std::sync::OnceLock;
2+
13
use erased_set::ErasedSyncSet;
2-
use once_cell::sync::OnceCell;
34
#[cfg(feature = "metrics")]
45
use prometheus_client::{encoding::text::encode, registry::Registry};
56
#[cfg(not(feature = "metrics"))]
67
type Registry = ();
78

8-
static CORE: OnceCell<Core> = OnceCell::new();
9+
static CORE: OnceLock<Core> = OnceLock::new();
910

1011
/// Core is the base metrics struct.
1112
///

0 commit comments

Comments
 (0)