oauth2_broker/ext/request_signer.rs
1//! Request signing contracts that let downstream crates attach broker-issued
2//! tokens to arbitrary HTTP clients.
3
4// self
5use crate::auth::TokenRecord;
6
7/// Describes how to attach a [`TokenRecord`] to an outbound request without
8/// constraining the HTTP client type.
9///
10/// The trait is intentionally generic over both the request and error types so
11/// implementers can integrate with any client builder (`reqwest`, `surf`, a
12/// bespoke SDK, etc.) while keeping `oauth2-broker` free of those dependencies.
13pub trait RequestSignerExt<Request, Error>
14where
15 Self: Send + Sync,
16{
17 /// Consumes (or clones) the provided request and injects authorization state
18 /// derived from the [`TokenRecord`].
19 fn attach_token(&self, request: Request, record: &TokenRecord) -> Result<Request, Error>;
20}