Skip to main content

X402Layer

Struct X402Layer 

Source
pub struct X402Layer<TSource> { /* private fields */ }
Available on crate feature server only.
Expand description

Tower layer produced by super::X402Middleware::with_price_tag.

Implementations§

Source§

impl X402Layer<StaticPriceTags>

Source

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.

Source

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.

Source

pub fn with_siwx(self, gate: SiwxGate) -> Result<Self, BuildError>

Available on crate feature 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.

Source

pub fn with_auth_only(self, gate: SiwxGate) -> Result<Self, BuildError>

Available on crate feature 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>

Source

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.

Source

pub fn with_siwx(self, gate: SiwxGate) -> Self

Available on crate feature siwx only.

Enables SIWX access-grant and 402 challenges on this route.

Source

pub fn with_auth_only(self, gate: SiwxGate) -> Self

Available on crate feature siwx only.

Enables SIWX with auth-only access-grant on this route.

Source§

impl<TSource> X402Layer<TSource>

Source

pub fn with_scheme( self, network: ChainIdPattern, scheme: impl SchemeNetworkServer + 'static, ) -> Self

Registers a scheme/network adapter on the owned resource server.

Source

pub fn with_extension(self, extension: impl Extension + 'static) -> Self

Registers a protocol extension advertised on 402 responses.

Source

pub fn with_description(self, description: String) -> Self

Description copied onto 402 resource.description.

Source

pub fn with_mime_type(self, mime: String) -> Self

MIME type copied onto 402 resource.mimeType.

Source

pub fn with_resource(self, resource: Url) -> Self

Pins ResourceInfo.url for this route. Does not waive base_url.

Source

pub fn with_settlement_tracker( self, tracker: BackgroundSettlementTracker, ) -> Self

In-flight counter for SettlementMode::Background settle tasks.

Source

pub fn with_hooks<H>(self, hooks: H) -> Self
where H: GateHooks + 'static,

HTTP-layer hooks (GrantAccess slot).

Trait Implementations§

Source§

impl<TSource: Clone> Clone for X402Layer<TSource>

Source§

fn clone(&self) -> X402Layer<TSource>

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<TSource: Debug> Debug for X402Layer<TSource>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S, TSource> Layer<S> for X402Layer<TSource>
where S: Service<Request, Response = Response, Error = Infallible> + Clone + Send + Sync + 'static, S::Future: Send + 'static, TSource: PriceTagSource,

Source§

type Service = X402MiddlewareService<TSource>

The wrapped service
Source§

fn layer(&self, inner: S) -> Self::Service

Wrap the given service with the middleware, returning a new service that has been decorated with the middleware.

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> 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more