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.

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

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 (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 six required wire fields.

Source

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

Attaches the scheme-specific extra blob.

Source

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

Passes through an optional extra blob.

Source§

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

Source

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

Core fields including maxTimeoutSeconds must be equal. Server-declared extra is a subset of accepted.extra.

Source

pub fn matches_payload_accepted_with_dynamic( &self, accepted: &Self, dynamic_extra_fields: &[&str], ) -> bool

Like Self::matches_payload_accepted, omitting dynamic_extra_fields from both extras before the subset check.

Source§

impl PaymentRequirements

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,

Converts all-string wire requirements into a 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<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, Option<TExtra>: Freeze,

§

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

§

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

§

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

§

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

§

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

§

impl<TScheme, TAmount, TAddress, TExtra> UnwindSafe for PaymentRequirements<TScheme, TAmount, TAddress, TExtra>
where TScheme: UnwindSafe, TAmount: UnwindSafe, TAddress: UnwindSafe, Option<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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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