Skip to main content

Signer

Struct Signer 

Source
pub struct Signer<K: SigningCredential> { /* private fields */ }
Expand description

Loads credentials and atomically signs request heads.

The service-specific SignRequest runs against a private candidate. Only the candidate URI and headers are committed after successful signing.

Implementations§

Source§

impl<K: SigningCredential> Signer<K>

Source

pub fn new( ctx: Context, loader: impl ProvideCredential<Credential = K>, builder: impl SignRequest<Credential = K>, ) -> Self

Create a new signer.

Source

pub fn with_context(self, ctx: Context) -> Self

Replace the context while keeping the credential provider, request signer, and shared credential cache.

Source

pub fn with_credential_provider( self, provider: impl ProvideCredential<Credential = K>, ) -> Self

Replace the credential provider while keeping context and request signer, and create an isolated empty credential cache.

Source

pub fn with_request_signer( self, signer: impl SignRequest<Credential = K>, ) -> Self

Replace the request signer while keeping context and credential provider.

Source

pub async fn sign( &self, req: &mut Parts, expires_in: Option<Duration>, ) -> Result<()>

Sign a wire-ready request head.

The request URI must satisfy the input contract of the configured SignRequest. Built-in signers require an authority and expect path and query data to be percent-encoded exactly once before this call. Signing does not perform general-purpose URI encoding for the caller.

If credential loading or request signing returns an error, req is unchanged. On success, only req.uri and req.headers may change; the method, version, and extensions retain their input values.

expires_in is a service-specific validity input and does not universally select query authentication. The configured service signer and credential type determine how it is interpreted.

Cached credentials must be fresh according to SigningCredential::is_valid and usable through SignRequest::required_valid_until. A refreshed credential only needs to satisfy the exact operation deadline. Credential refresh is serialized per shared cache. A failed refresh is not cached, so the next waiting or later caller can retry. Provider errors are returned without internal retry or fallback to the previous cached credential. Request signing runs after refresh coordination has completed and remains concurrent.

Trait Implementations§

Source§

impl<K: Clone + SigningCredential> Clone for Signer<K>

Source§

fn clone(&self) -> Signer<K>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: SigningCredential> Debug for Signer<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<K> !RefUnwindSafe for Signer<K>

§

impl<K> !UnwindSafe for Signer<K>

§

impl<K> Freeze for Signer<K>
where Arc<dyn ProvideCredentialDyn<Credential = K>>: Freeze, Arc<dyn SignRequestDyn<Credential = K>>: Freeze, Arc<Mutex<Option<K>>>: Freeze,

§

impl<K> Send for Signer<K>
where Arc<dyn ProvideCredentialDyn<Credential = K>>: Send, Arc<dyn SignRequestDyn<Credential = K>>: Send, Arc<Mutex<Option<K>>>: Send,

§

impl<K> Sync for Signer<K>
where Arc<dyn ProvideCredentialDyn<Credential = K>>: Sync, Arc<dyn SignRequestDyn<Credential = K>>: Sync, Arc<Mutex<Option<K>>>: Sync,

§

impl<K> Unpin for Signer<K>
where Arc<dyn ProvideCredentialDyn<Credential = K>>: Unpin, Arc<dyn SignRequestDyn<Credential = K>>: Unpin, Arc<Mutex<Option<K>>>: Unpin,

§

impl<K> UnsafeUnpin for Signer<K>
where Arc<dyn ProvideCredentialDyn<Credential = K>>: UnsafeUnpin, Arc<dyn SignRequestDyn<Credential = K>>: UnsafeUnpin, Arc<Mutex<Option<K>>>: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.