pub enum PartnerFee {
Single(PartnerFeeEntry),
Multiple(Vec<PartnerFeeEntry>),
}Expand description
Partner fee attached to a CoW Protocol order (schema v1.14.0).
Can be a single PartnerFeeEntry or a list of entries. The most common
form is a single volume-based entry: PartnerFee::single(PartnerFeeEntry::volume(50, "0x...")).
Use get_partner_fee_bps to extract the first volumeBps value.
Variants§
Single(PartnerFeeEntry)
A single fee policy.
Multiple(Vec<PartnerFeeEntry>)
A list of fee policies (one per fee type).
Implementations§
Source§impl PartnerFee
impl PartnerFee
Sourcepub const fn single(entry: PartnerFeeEntry) -> Self
pub const fn single(entry: PartnerFeeEntry) -> Self
Convenience constructor for the common single-entry case.
Most integrations use a single fee policy. Wrap a
PartnerFeeEntry in PartnerFee::Single for ergonomic use.
§Parameters
entry— the fee policy entry (usePartnerFeeEntry::volume,PartnerFeeEntry::surplus, orPartnerFeeEntry::price_improvementto create one).
§Returns
A PartnerFee::Single wrapping the given entry.
§Example
use cow_rs::app_data::{PartnerFee, PartnerFeeEntry};
let fee = PartnerFee::single(PartnerFeeEntry::volume(50, "0xAddr"));
assert!(fee.is_single());
assert_eq!(fee.count(), 1);Sourcepub fn entries(&self) -> impl Iterator<Item = &PartnerFeeEntry>
pub fn entries(&self) -> impl Iterator<Item = &PartnerFeeEntry>
Sourcepub const fn is_multiple(&self) -> bool
pub const fn is_multiple(&self) -> bool
Returns true if this is a multi-entry partner fee.
Sourcepub const fn count(&self) -> usize
pub const fn count(&self) -> usize
Returns the number of fee entries: 1 for Single,
or the vector length for Multiple.
use cow_rs::app_data::{PartnerFee, PartnerFeeEntry};
let fee = PartnerFee::single(PartnerFeeEntry::volume(50, "0x1234"));
assert_eq!(fee.count(), 1);
let multi = PartnerFee::Multiple(vec![
PartnerFeeEntry::volume(50, "0x1234"),
PartnerFeeEntry::surplus(30, 100, "0x5678"),
]);
assert_eq!(multi.count(), 2);Trait Implementations§
Source§impl Clone for PartnerFee
impl Clone for PartnerFee
Source§fn clone(&self) -> PartnerFee
fn clone(&self) -> PartnerFee
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PartnerFee
impl Debug for PartnerFee
Source§impl<'de> Deserialize<'de> for PartnerFee
impl<'de> Deserialize<'de> for PartnerFee
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for PartnerFee
impl Display for PartnerFee
Auto Trait Implementations§
impl Freeze for PartnerFee
impl RefUnwindSafe for PartnerFee
impl Send for PartnerFee
impl Sync for PartnerFee
impl Unpin for PartnerFee
impl UnsafeUnpin for PartnerFee
impl UnwindSafe for PartnerFee
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.