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)] 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::*;