Skip to content

Commit 6384e86

Browse files
committed
chore(docs): update api docs
1 parent 7db212c commit 6384e86

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

httpsig-hyper/src/hyper_http.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,14 @@ pub trait MessageSignatureRes {
135135

136136
/* --------------------------------------- */
137137
#[cfg(feature = "blocking")]
138-
/// A trait about http message signature for request with synchronous signing/verifying key
138+
/// Synchronous counterpart of [`MessageSignatureReq`].
139+
///
140+
/// Every method delegates to the corresponding async method via `futures::executor::block_on`.
141+
///
142+
/// # Panics
143+
///
144+
/// All methods will panic if called from within an async runtime (e.g. a `tokio` task).
145+
/// Use the async [`MessageSignatureReq`] methods instead when you are already in an async context.
139146
pub trait MessageSignatureReqSync: MessageSignatureReq {
140147
fn set_message_signature_sync<T>(
141148
&mut self,
@@ -170,7 +177,14 @@ pub trait MessageSignatureReqSync: MessageSignatureReq {
170177
}
171178

172179
#[cfg(feature = "blocking")]
173-
/// A trait about http message signature for response with synchronous signing/verifying key
180+
/// Synchronous counterpart of [`MessageSignatureRes`].
181+
///
182+
/// Every method delegates to the corresponding async method via `futures::executor::block_on`.
183+
///
184+
/// # Panics
185+
///
186+
/// All methods will panic if called from within an async runtime (e.g. a `tokio` task).
187+
/// Use the async [`MessageSignatureRes`] methods instead when you are already in an async context.
174188
pub trait MessageSignatureResSync: MessageSignatureRes {
175189
fn set_message_signature_sync<T, B>(
176190
&mut self,

httpsig-hyper/src/lib.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,24 @@
11
//! # httpsig-hyper
22
//!
33
//! `httpsig-hyper` is a crate that provides a convenient API for `Hyper` users to handle HTTP signatures.
4-
//! This crate extends hyper's https request and response messages with the ability to generate and verify HTTP signatures.
4+
//! This crate extends hyper's http request and response messages with the ability to generate and verify HTTP signatures.
55
//! Additionally it also provides a way to set and verify content-digest header.
6+
//!
7+
//! ## Async-first design
8+
//!
9+
//! The primary API is fully async, allowing concurrent processing of multiple signatures via
10+
//! [`MessageSignatureReq`] and [`MessageSignatureRes`].
11+
//!
12+
//! ## Blocking API
13+
//!
14+
//! When the `blocking` feature is enabled (on by default), synchronous wrappers are provided via
15+
//! [`MessageSignatureReqSync`] and [`MessageSignatureResSync`]. These use `futures::executor::block_on`
16+
//! internally and are intended **exclusively for non-async contexts**.
17+
//!
18+
//! # Panics
19+
//!
20+
//! Calling any `*_sync` method from within an async runtime (e.g. inside a `tokio::spawn` task)
21+
//! will panic. If you are already in an async context, use the async methods directly.
622
723
mod error;
824
mod hyper_content_digest;

0 commit comments

Comments
 (0)