#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.scheme: TSchemeThe payment scheme, e.g. "exact" or "upto".
network: ChainIdCAIP-2 chain identifier (e.g. "eip155:8453").
amount: TAmountPayment amount in the token’s smallest unit (as string for precision).
pay_to: TAddressRecipient address on the target chain.
max_timeout_seconds: u64Maximum time in seconds the authorization remains valid.
asset: TAddressToken asset address / mint.
extra: Option<TExtra>Scheme-specific auxiliary data.
Implementations§
Source§impl<TScheme, TAmount, TAddress, TExtra> PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme, TAmount, TAddress, TExtra> PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
Sourcepub const fn new(
scheme: TScheme,
network: ChainId,
amount: TAmount,
pay_to: TAddress,
asset: TAddress,
max_timeout_seconds: u64,
) -> Self
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.
Sourcepub fn with_extra(self, extra: TExtra) -> Self
pub fn with_extra(self, extra: TExtra) -> Self
Builder: attaches the scheme-specific extra blob.
Sourcepub fn with_optional_extra(self, extra: Option<TExtra>) -> Self
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
impl PaymentRequirements
Sourcepub fn matches_payload_accepted(&self, accepted: &Self) -> bool
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).
Sourcepub fn as_concrete<TScheme, TAmount, TAddress, TExtra>(
&self,
) -> Option<PaymentRequirements<TScheme, TAmount, TAddress, TExtra>>
pub fn as_concrete<TScheme, TAmount, TAddress, TExtra>( &self, ) -> Option<PaymentRequirements<TScheme, TAmount, TAddress, TExtra>>
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>
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>
fn clone(&self) -> PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<TScheme: Debug, TAmount: Debug, TAddress: Debug, TExtra: Debug> Debug for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme: Debug, TAmount: Debug, TAddress: Debug, TExtra: Debug> Debug for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
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>,
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>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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>
impl<TScheme: PartialEq, TAmount: PartialEq, TAddress: PartialEq, TExtra: PartialEq> PartialEq for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
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).
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§impl<TScheme, TAmount, TAddress, TExtra> Serialize for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme, TAmount, TAddress, TExtra> Serialize for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
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>
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>
impl<TScheme, TAmount, TAddress, TExtra> Sync for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme, TAmount, TAddress, TExtra> Unpin for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme, TAmount, TAddress, TExtra> UnsafeUnpin for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
impl<TScheme, TAmount, TAddress, TExtra> UnwindSafe for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.