pub struct Metadata {Show 13 fields
pub referrer: Option<Referrer>,
pub utm: Option<Utm>,
pub quote: Option<Quote>,
pub order_class: Option<OrderClass>,
pub hooks: Option<OrderInteractionHooks>,
pub widget: Option<Widget>,
pub partner_fee: Option<PartnerFee>,
pub replaced_order: Option<ReplacedOrder>,
pub signer: Option<String>,
pub bridging: Option<Bridging>,
pub flashloan: Option<Flashloan>,
pub wrappers: Option<Vec<WrapperEntry>>,
pub user_consents: Option<Vec<UserConsent>>,
}Expand description
Metadata container — all fields are optional.
Each field corresponds to a section of the CoW Protocol app-data
schema. Fields are serialised only when Some (via
#[serde(skip_serializing_if = "Option::is_none")]), keeping the JSON
compact.
Use the builder methods (with_*) to populate fields, or the has_*
predicates to check which fields are set.
§Example
use cow_app_data::{Metadata, Quote, Referrer};
let meta = Metadata::default()
.with_referrer(Referrer::code("COWRS-PARTNER"))
.with_quote(Quote::new(50));
assert!(meta.has_referrer());
assert!(meta.has_quote());
assert!(!meta.has_hooks());Fields§
§referrer: Option<Referrer>Referrer address for partner attribution.
utm: Option<Utm>UTM tracking parameters.
quote: Option<Quote>Quote-level slippage settings.
order_class: Option<OrderClass>Classification of the order intent.
hooks: Option<OrderInteractionHooks>Pre- and post-interaction hooks.
widget: Option<Widget>Widget metadata when the order originates from a widget integration.
partner_fee: Option<PartnerFee>Protocol fee charged by an integration partner.
replaced_order: Option<ReplacedOrder>UID of a previous order that this order replaces.
signer: Option<String>Signer wallet address (for EIP-1271 or other non-EOA signers).
bridging: Option<Bridging>Cross-chain bridging metadata (if the order used a bridge).
flashloan: Option<Flashloan>Flash loan metadata (if the order used a flash loan).
wrappers: Option<Vec<WrapperEntry>>Token wrapper entries applied during execution.
user_consents: Option<Vec<UserConsent>>User consent records attached to this order.
Implementations§
Source§impl Metadata
impl Metadata
Sourcepub fn with_referrer(self, referrer: Referrer) -> Metadata
pub fn with_referrer(self, referrer: Referrer) -> Metadata
Sourcepub const fn with_quote(self, quote: Quote) -> Metadata
pub const fn with_quote(self, quote: Quote) -> Metadata
Sourcepub const fn with_order_class(self, order_class: OrderClass) -> Metadata
pub const fn with_order_class(self, order_class: OrderClass) -> Metadata
Set the order class classification.
§Parameters
order_class— theOrderClasswrapping anOrderClassKind.
§Returns
self with order_class set.
Sourcepub fn with_hooks(self, hooks: OrderInteractionHooks) -> Metadata
pub fn with_hooks(self, hooks: OrderInteractionHooks) -> Metadata
Set the pre- and post-settlement interaction hooks.
§Parameters
hooks— theOrderInteractionHookscontaining pre/post lists.
§Returns
self with hooks set.
Sourcepub fn with_widget(self, widget: Widget) -> Metadata
pub fn with_widget(self, widget: Widget) -> Metadata
Sourcepub fn with_partner_fee(self, fee: PartnerFee) -> Metadata
pub fn with_partner_fee(self, fee: PartnerFee) -> Metadata
Set the partner fee policy.
§Parameters
fee— thePartnerFee(single or multi-entry).
§Returns
self with partner_fee set.
Sourcepub fn with_replaced_order(self, order: ReplacedOrder) -> Metadata
pub fn with_replaced_order(self, order: ReplacedOrder) -> Metadata
Set the replaced-order reference.
§Parameters
order— theReplacedOrdercontaining the UID of the order being superseded.
§Returns
self with replaced_order set.
Sourcepub fn with_signer(self, signer: impl Into<String>) -> Metadata
pub fn with_signer(self, signer: impl Into<String>) -> Metadata
Sourcepub fn with_bridging(self, bridging: Bridging) -> Metadata
pub fn with_bridging(self, bridging: Bridging) -> Metadata
Sourcepub fn with_flashloan(self, flashloan: Flashloan) -> Metadata
pub fn with_flashloan(self, flashloan: Flashloan) -> Metadata
Sourcepub fn with_wrappers(self, wrappers: Vec<WrapperEntry>) -> Metadata
pub fn with_wrappers(self, wrappers: Vec<WrapperEntry>) -> Metadata
Set the token WrapperEntry records.
§Parameters
wrappers— list of wrapper entries applied during execution.
§Returns
self with wrappers set.
Sourcepub fn with_user_consents(self, consents: Vec<UserConsent>) -> Metadata
pub fn with_user_consents(self, consents: Vec<UserConsent>) -> Metadata
Set the UserConsent records for terms of service acceptance.
§Parameters
consents— list of consent records.
§Returns
self with user_consents set.
Sourcepub const fn has_referrer(&self) -> bool
pub const fn has_referrer(&self) -> bool
Returns true if a referrer tracking code is set.
Sourcepub const fn has_order_class(&self) -> bool
pub const fn has_order_class(&self) -> bool
Returns true if an order class classification is set.
Sourcepub const fn has_widget(&self) -> bool
pub const fn has_widget(&self) -> bool
Returns true if widget integration metadata is set.
Sourcepub const fn has_partner_fee(&self) -> bool
pub const fn has_partner_fee(&self) -> bool
Returns true if a partner fee is set.
Sourcepub const fn has_replaced_order(&self) -> bool
pub const fn has_replaced_order(&self) -> bool
Returns true if a replaced-order reference is set.
Sourcepub const fn has_signer(&self) -> bool
pub const fn has_signer(&self) -> bool
Returns true if a signer address override is set.
Sourcepub const fn has_bridging(&self) -> bool
pub const fn has_bridging(&self) -> bool
Returns true if cross-chain bridging metadata is set.
Sourcepub const fn has_flashloan(&self) -> bool
pub const fn has_flashloan(&self) -> bool
Returns true if flash loan metadata is set.
Sourcepub fn has_wrappers(&self) -> bool
pub fn has_wrappers(&self) -> bool
Returns true if at least one token wrapper entry is set.
Sourcepub fn has_user_consents(&self) -> bool
pub fn has_user_consents(&self) -> bool
Returns true if at least one user consent record is set.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
impl<'de> Deserialize<'de> for Metadata
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metadata, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Metadata, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Metadata
impl Serialize for Metadata
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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,
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>
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>
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.