From 025452e96a29e4e3db1ff406282f43f2d8cfc821 Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Wed, 22 Jul 2026 22:43:30 +0900 Subject: [PATCH 1/2] feat: make `tracing` dependency optional (default: enabled) Supersedes #30. The `tracing` dependency of the `httpsig` crate is now gated behind a new `tracing` feature, enabled by default so that existing users keep their log output. Unlike #30, log call sites are left untouched: the `trace` facade module now provides no-op macros when the feature is disabled, so a missing cfg guard can never break a feature combination (#30 failed to compile with `--features rsa-signature` alone). The dependency is also declared with `default-features = false`, which drops `tracing-attributes` from the dependency graph since only the bang-style macros are used. Verified: cargo check/test across default, --no-default-features, rsa-signature with and without tracing, --all-features, and the whole workspace. Co-authored-by: keskalukasfri <270303466+keskalukasfri@users.noreply.github.com> --- httpsig/Cargo.toml | 6 +++--- httpsig/src/trace.rs | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/httpsig/Cargo.toml b/httpsig/Cargo.toml index 80e74ab..886123c 100644 --- a/httpsig/Cargo.toml +++ b/httpsig/Cargo.toml @@ -13,12 +13,13 @@ rust-version.workspace = true # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [features] -default = [] +default = ["tracing"] rsa-signature = ["rsa"] +tracing = ["dep:tracing"] [dependencies] thiserror = { version = "2.0.19" } -tracing = { version = "0.1.44" } +tracing = { version = "0.1.44", default-features = false, optional = true } rustc-hash = { version = "2.1.3" } indexmap = { version = "2.14.0" } rand = { version = "0.10.2" } @@ -56,4 +57,3 @@ base64 = { version = "0.22.1" } # for rfc8941 structured field values sfv = { version = "0.15.0" } - diff --git a/httpsig/src/trace.rs b/httpsig/src/trace.rs index 7255693..3e5cc21 100644 --- a/httpsig/src/trace.rs +++ b/httpsig/src/trace.rs @@ -1,2 +1,43 @@ +#[cfg(feature = "tracing")] #[allow(unused)] -pub use tracing::{debug, error, info, trace, warn}; +pub(crate) use tracing::{debug, error, info, trace, warn}; + +/// No-op macros used when the `tracing` feature is disabled. +/// They expand to `()` so that they are usable both in statement and +/// expression positions, like the original `tracing` macros. +/// `warn` is defined as `warn_` and re-exported, since a macro named +/// `warn` conflicts with the built-in `warn` attribute (E0659). +#[cfg(not(feature = "tracing"))] +mod noop { + #![allow(unused_macros)] + macro_rules! debug { + ($($arg:tt)*) => { + () + }; + } + macro_rules! error { + ($($arg:tt)*) => { + () + }; + } + macro_rules! info { + ($($arg:tt)*) => { + () + }; + } + macro_rules! trace { + ($($arg:tt)*) => { + () + }; + } + macro_rules! warn_ { + ($($arg:tt)*) => { + () + }; + } + #[allow(unused_imports)] + pub(crate) use {debug, error, info, trace, warn_ as warn}; +} +#[cfg(not(feature = "tracing"))] +#[allow(unused)] +pub(crate) use noop::*; From 46663ef976d2e9bcd1dbd3c6b2b0d52161c2a395 Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Wed, 22 Jul 2026 22:45:36 +0900 Subject: [PATCH 2/2] fix: httpsig-hyper fails to build with --no-default-features --- httpsig-hyper/src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/httpsig-hyper/src/lib.rs b/httpsig-hyper/src/lib.rs index 691a392..00941ff 100644 --- a/httpsig-hyper/src/lib.rs +++ b/httpsig-hyper/src/lib.rs @@ -58,9 +58,9 @@ impl std::str::FromStr for ContentDigestType { pub use error::{HyperDigestError, HyperDigestResult, HyperSigError, HyperSigResult}; pub use httpsig::prelude; pub use hyper_content_digest::{ContentDigest, RequestContentDigest, ResponseContentDigest}; -pub use hyper_http::{ - MessageSignature, MessageSignatureReq, MessageSignatureReqSync, MessageSignatureRes, MessageSignatureResSync, -}; +pub use hyper_http::{MessageSignature, MessageSignatureReq, MessageSignatureRes}; +#[cfg(feature = "blocking")] +pub use hyper_http::{MessageSignatureReqSync, MessageSignatureResSync}; /* ----------------------------------------------------------------- */ #[cfg(test)]