Prechádzať zdrojové kódy

add docs and feature restriction

lescuer97 1 deň pred
rodič
commit
6d81301729

+ 4 - 0
crates/cdk-http-client/Cargo.toml

@@ -11,6 +11,7 @@ license.workspace = true
 readme = "README.md"
 
 [features]
+# Backend features are mutually exclusive; enable only one.
 default = ["bitreq"]
 reqwest = ["dep:reqwest", "dep:regex"]
 bitreq = ["dep:bitreq", "dep:serde_urlencoded", "dep:regex"]
@@ -34,3 +35,6 @@ serde = { workspace = true }
 
 [lints]
 workspace = true
+
+[package.metadata.docs.rs]
+features = ["bitreq"]

+ 9 - 2
crates/cdk-http-client/README.md

@@ -2,8 +2,15 @@
 
 HTTP client abstraction for the Cashu Development Kit (CDK).
 
-This crate provides an HTTP client wrapper that abstracts the underlying HTTP library (reqwest),
-allowing other CDK crates to avoid direct dependencies on reqwest.
+This crate provides an HTTP client wrapper that abstracts the underlying HTTP library
+(reqwest or bitreq), allowing other CDK crates to avoid direct dependencies on a specific backend.
+
+## Features
+
+- `bitreq` (default) - use bitreq as the HTTP backend
+- `reqwest` - use reqwest as the HTTP backend
+
+These features are mutually exclusive. Enable only one backend at a time.
 
 ## Usage
 

+ 6 - 2
crates/cdk-http-client/src/lib.rs

@@ -1,7 +1,8 @@
 //! HTTP client abstraction for CDK
 //!
-//! This crate provides an HTTP client wrapper that abstracts the underlying HTTP library (reqwest).
-//! Using this crate allows other CDK crates to avoid direct dependencies on reqwest.
+//! This crate provides an HTTP client wrapper that abstracts the underlying HTTP library
+//! (reqwest or bitreq).
+//! Using this crate allows other CDK crates to avoid direct dependencies on a specific backend.
 //!
 //! # Example
 //!
@@ -20,6 +21,9 @@
 //! }
 //! ```
 
+#[cfg(all(feature = "reqwest", feature = "bitreq"))]
+compile_error!("Features \"reqwest\" and \"bitreq\" are mutually exclusive. Enable only one.");
+
 mod backends;
 mod client;
 mod error;