pub struct X402Layer<TSource> { /* private fields */ }server only.Expand description
Tower layer produced by super::X402Middleware::with_price_tag.
Implementations§
Source§impl X402Layer<StaticPriceTags>
impl X402Layer<StaticPriceTags>
Sourcepub fn with_price_tag(self, price_tag: PriceTag) -> Result<Self, BuildError>
pub fn with_price_tag(self, price_tag: PriceTag) -> Result<Self, BuildError>
Adds another static payment option.
§Errors
BuildError when the appended tag (or the existing list with the
current settlement mode) is invalid.
Sourcepub fn with_settlement_mode(
self,
mode: SettlementMode,
) -> Result<Self, BuildError>
pub fn with_settlement_mode( self, mode: SettlementMode, ) -> Result<Self, BuildError>
After-handler settle scheduler for the authorization payment flow.
Not a paymentFlow. Sequential (default) is spec authorization:
settle after the handler, then attach Payment-Response. Concurrent
overlaps that settle with the handler and still waits. Background does
not wait and does not attach a receipt. Concurrent and Background are
illegal with upfront / escrow.
§Errors
BuildError::Mode when mode is incompatible with a static tag’s flow.
Sourcepub fn with_siwx(self, gate: SiwxGate) -> Result<Self, BuildError>
Available on crate feature siwx only.
pub fn with_siwx(self, gate: SiwxGate) -> Result<Self, BuildError>
siwx only.Enables SIWX access-grant and 402 challenges on this route.
§Errors
BuildError::EmptyPriceTags when this replacement is not auth-only
and the static tag list is empty.
Sourcepub fn with_auth_only(self, gate: SiwxGate) -> Result<Self, BuildError>
Available on crate feature siwx only.
pub fn with_auth_only(self, gate: SiwxGate) -> Result<Self, BuildError>
siwx only.Enables SIWX with auth-only access-grant on this route.
§Errors
BuildError from static re-validation after the replacement.
Source§impl X402Layer<DynamicPriceTags>
impl X402Layer<DynamicPriceTags>
Sourcepub fn with_settlement_mode(
self,
mode: SettlementMode,
) -> Result<Self, BuildError>
pub fn with_settlement_mode( self, mode: SettlementMode, ) -> Result<Self, BuildError>
After-handler settle scheduler for the authorization payment flow.
Same semantics as X402Layer<StaticPriceTags>::with_settlement_mode.
Dynamic tags are resolved per request; incompatible upfront /
escrow combinations fail at request time, not here.
§Errors
Always Ok after storing mode.
Sourcepub fn with_siwx(self, gate: SiwxGate) -> Self
Available on crate feature siwx only.
pub fn with_siwx(self, gate: SiwxGate) -> Self
siwx only.Enables SIWX access-grant and 402 challenges on this route.
Sourcepub fn with_auth_only(self, gate: SiwxGate) -> Self
Available on crate feature siwx only.
pub fn with_auth_only(self, gate: SiwxGate) -> Self
siwx only.Enables SIWX with auth-only access-grant on this route.
Source§impl<TSource> X402Layer<TSource>
impl<TSource> X402Layer<TSource>
Sourcepub fn with_scheme(
self,
network: ChainIdPattern,
scheme: impl SchemeNetworkServer + 'static,
) -> Self
pub fn with_scheme( self, network: ChainIdPattern, scheme: impl SchemeNetworkServer + 'static, ) -> Self
Registers a scheme/network adapter on the owned resource server.
Sourcepub fn with_extension(self, extension: impl Extension + 'static) -> Self
pub fn with_extension(self, extension: impl Extension + 'static) -> Self
Registers a protocol extension advertised on 402 responses.
Sourcepub fn with_description(self, description: String) -> Self
pub fn with_description(self, description: String) -> Self
Description copied onto 402 resource.description.
Sourcepub fn with_mime_type(self, mime: String) -> Self
pub fn with_mime_type(self, mime: String) -> Self
MIME type copied onto 402 resource.mimeType.
Sourcepub fn with_resource(self, resource: Url) -> Self
pub fn with_resource(self, resource: Url) -> Self
Pins ResourceInfo.url for this route. Does not waive base_url.
Sourcepub fn with_settlement_tracker(
self,
tracker: BackgroundSettlementTracker,
) -> Self
pub fn with_settlement_tracker( self, tracker: BackgroundSettlementTracker, ) -> Self
In-flight counter for SettlementMode::Background settle tasks.
Sourcepub fn with_hooks<H>(self, hooks: H) -> Selfwhere
H: GateHooks + 'static,
pub fn with_hooks<H>(self, hooks: H) -> Selfwhere
H: GateHooks + 'static,
HTTP-layer hooks (GrantAccess slot).
Trait Implementations§
Auto Trait Implementations§
impl<TSource> !RefUnwindSafe for X402Layer<TSource>
impl<TSource> !UnwindSafe for X402Layer<TSource>
impl<TSource> Freeze for X402Layer<TSource>where
TSource: Freeze,
impl<TSource> Send for X402Layer<TSource>where
TSource: Send,
impl<TSource> Sync for X402Layer<TSource>where
TSource: Sync,
impl<TSource> Unpin for X402Layer<TSource>where
TSource: Unpin,
impl<TSource> UnsafeUnpin for X402Layer<TSource>where
TSource: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more