pub struct PreferChain(/* private fields */);Expand description
Selector that prefers specific chains in priority order.
Patterns are tried in order; the first matching candidate is returned. If no patterns match, falls back to the first available candidate.
§Example
use x402_types::scheme::client::PreferChain;
use x402_types::chain::ChainIdPattern;
// Prefer Base, then any EVM chain, then anything else
let selector = PreferChain::new(vec![
"eip155:8453".parse().unwrap(), // Base mainnet
"eip155:*".parse().unwrap(), // Any EVM chain
]);Implementations§
Source§impl PreferChain
impl PreferChain
Sourcepub fn new<P: Into<Vec<ChainIdPattern>>>(patterns: P) -> Self
pub fn new<P: Into<Vec<ChainIdPattern>>>(patterns: P) -> Self
Creates a new chain preference selector.
Sourcepub fn or_chain<P: Into<Vec<ChainIdPattern>>>(self, patterns: P) -> PreferChain
pub fn or_chain<P: Into<Vec<ChainIdPattern>>>(self, patterns: P) -> PreferChain
Adds additional chain patterns with lower priority.
Trait Implementations§
Source§impl PaymentSelector for PreferChain
impl PaymentSelector for PreferChain
Source§fn select<'a>(
&self,
candidates: &'a [PaymentCandidate],
) -> Option<&'a PaymentCandidate>
fn select<'a>( &self, candidates: &'a [PaymentCandidate], ) -> Option<&'a PaymentCandidate>
Selects a payment candidate from the available options.
Auto Trait Implementations§
impl Freeze for PreferChain
impl RefUnwindSafe for PreferChain
impl Send for PreferChain
impl Sync for PreferChain
impl Unpin for PreferChain
impl UnwindSafe for PreferChain
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
Mutably borrows from an owned value. Read more