Skip to main content

ClientExtension

Trait ClientExtension 

Source
pub trait ClientExtension: Send + Sync {
    // Required method
    fn key(&self) -> &'static str;

    // Provided methods
    fn enrich_payment_payload<'a>(
        &'a self,
        payload_b64: &'a str,
        _payment_required: &'a PaymentRequired,
    ) -> impl Future<Output = Result<String, ClientError>> + Send + 'a { ... }
    fn on_payment_required<'a>(
        &'a self,
        _payment_required: &'a PaymentRequired,
        _request_url: &'a str,
    ) -> impl Future<Output = HeaderMap> + Send + 'a { ... }
}
Expand description

Client-side extension. Copy of the crate::ClientHooks / DynClientExtension split: RPITIT is not object-safe, so stored values are DynClientExtension.

SIWX implements Self::on_payment_required only (HTTP SIGN-IN-WITH-X). Builder-code implements Self::enrich_payment_payload. Do not fold SIWX into enrich.

Required Methods§

Source

fn key(&self) -> &'static str

Wire key ("sign-in-with-x", "builder-code", …).

Provided Methods§

Source

fn enrich_payment_payload<'a>( &'a self, payload_b64: &'a str, _payment_required: &'a PaymentRequired, ) -> impl Future<Output = Result<String, ClientError>> + Send + 'a

Called after scheme signing. Default is a no-op (returns payload_b64).

Extensions that require a server declaration must no-op internally when payment_required.extensions does not advertise key.

Source

fn on_payment_required<'a>( &'a self, _payment_required: &'a PaymentRequired, _request_url: &'a str, ) -> impl Future<Output = HeaderMap> + Send + 'a

Official transportHooks.http.onPaymentRequired. Default empty.

request_url is the 402 response URL after redirects. SIWX returns SIGN-IN-WITH-X here and binds challenge origin to that URL.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§