Skip to main content

PaymentRequirements

Struct PaymentRequirements 

Source
#[non_exhaustive]
pub struct PaymentRequirements<TScheme = CompactString, TAmount = CompactString, TAddress = CompactString, TExtra = Value> { pub scheme: TScheme, pub network: ChainId, pub amount: TAmount, pub pay_to: TAddress, pub max_timeout_seconds: u64, pub asset: TAddress, pub extra: Option<TExtra>, }
Expand description

Payment terms set by the seller, carried inside PaymentRequired.accepts[].

Generic parameters allow concrete chain crates to specialise the scheme name, amount representation, addresses, and scheme-specific extra blob. The wire-level defaults are all strings plus an opaque JSON value for extra, mirroring the protocol exactly.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§scheme: TScheme

The payment scheme, e.g. "exact" or "upto".

§network: ChainId

CAIP-2 chain identifier (e.g. "eip155:8453").

§amount: TAmount

Payment amount in the token’s smallest unit (as string for precision).

§pay_to: TAddress

Recipient address on the target chain.

§max_timeout_seconds: u64

Maximum time in seconds the authorization remains valid.

§asset: TAddress

Token asset address / mint.

§extra: Option<TExtra>

Scheme-specific auxiliary data.

Implementations§

Source§

impl<TScheme, TAmount, TAddress, TExtra> PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Source

pub const fn new( scheme: TScheme, network: ChainId, amount: TAmount, pay_to: TAddress, asset: TAddress, max_timeout_seconds: u64, ) -> Self

Constructs the requirements from the six required wire fields. Use Self::with_extra / Self::with_optional_extra to attach the scheme-specific blob.

Source

pub fn with_extra(self, extra: TExtra) -> Self

Builder: attaches the scheme-specific extra blob.

Source

pub fn with_optional_extra(self, extra: Option<TExtra>) -> Self

Builder: passes through an optional extra blob (useful when the value is produced via Option::map upstream).

Source§

impl PaymentRequirements

Source

pub fn matches_payload_accepted(&self, accepted: &Self) -> bool

Returns true when accepted matches this requirement under Go FindMatchingRequirements rules (server.go): scheme, network, amount, asset, payTo must be equal.

maxTimeoutSeconds and extra are intentionally not compared (same as the foundation Go / Casper preflight convention).

Source

pub fn as_concrete<TScheme, TAmount, TAddress, TExtra>( &self, ) -> Option<PaymentRequirements<TScheme, TAmount, TAddress, TExtra>>
where TScheme: FromStr, TAmount: FromStr, TAddress: FromStr, TExtra: DeserializeOwned,

Attempts to convert the wire-level requirements (all-strings) into a concrete, strongly-typed variant.

Returns None if any component fails to parse.

Trait Implementations§

Source§

impl<TScheme: Clone, TAmount: Clone, TAddress: Clone, TExtra: Clone> Clone for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Source§

fn clone(&self) -> PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

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<TScheme: Debug, TAmount: Debug, TAddress: Debug, TExtra: Debug> Debug for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Source§

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

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

impl<'de, TScheme, TAmount, TAddress, TExtra> Deserialize<'de> for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Deserialize<'de>, TAmount: Deserialize<'de>, TAddress: Deserialize<'de>, TExtra: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<TScheme: Eq, TAmount: Eq, TAddress: Eq, TExtra: Eq> Eq for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Source§

impl<TScheme: PartialEq, TAmount: PartialEq, TAddress: PartialEq, TExtra: PartialEq> PartialEq for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Source§

fn eq( &self, other: &PaymentRequirements<TScheme, TAmount, TAddress, TExtra>, ) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<PaymentRequirements> for PriceTag

Matches a PriceTag against wire-level requirements on the five protocol-critical fields only (scheme / network / amount / asset / pay_to).

max_timeout_seconds and extra are deliberately ignored so enriched fields attached by the facilitator do not cause false negatives.

Source§

fn eq(&self, other: &PaymentRequirements) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<TScheme, TAmount, TAddress, TExtra> Serialize for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Serialize, TAmount: Serialize, TAddress: Serialize, TExtra: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<TScheme: PartialEq, TAmount: PartialEq, TAddress: PartialEq, TExtra: PartialEq> StructuralPartialEq for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>

Auto Trait Implementations§

§

impl<TScheme, TAmount, TAddress, TExtra> Freeze for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Freeze, TAmount: Freeze, TAddress: Freeze, TExtra: Freeze,

§

impl<TScheme, TAmount, TAddress, TExtra> RefUnwindSafe for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: RefUnwindSafe, TAmount: RefUnwindSafe, TAddress: RefUnwindSafe, TExtra: RefUnwindSafe,

§

impl<TScheme, TAmount, TAddress, TExtra> Send for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Send, TAmount: Send, TAddress: Send, TExtra: Send,

§

impl<TScheme, TAmount, TAddress, TExtra> Sync for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Sync, TAmount: Sync, TAddress: Sync, TExtra: Sync,

§

impl<TScheme, TAmount, TAddress, TExtra> Unpin for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: Unpin, TAmount: Unpin, TAddress: Unpin, TExtra: Unpin,

§

impl<TScheme, TAmount, TAddress, TExtra> UnsafeUnpin for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: UnsafeUnpin, TAmount: UnsafeUnpin, TAddress: UnsafeUnpin, TExtra: UnsafeUnpin,

§

impl<TScheme, TAmount, TAddress, TExtra> UnwindSafe for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: UnwindSafe, TAmount: UnwindSafe, TAddress: UnwindSafe, TExtra: UnwindSafe,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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