pub struct OrderInteractionHooks {
pub version: Option<String>,
pub pre: Option<Vec<CowHook>>,
pub post: Option<Vec<CowHook>>,
}Expand description
Pre- and post-settlement interaction hooks.
Contains optional lists of CowHook entries that the settlement
contract will execute before (pre) and after (post) the trade.
When both lists are empty, the field is typically omitted from the JSON.
§Example
use cow_app_data::{CowHook, OrderInteractionHooks};
let pre_hook =
CowHook::new("0x1234567890abcdef1234567890abcdef12345678", "0xabcdef00", "50000");
let hooks = OrderInteractionHooks::new(vec![pre_hook], vec![]);
assert!(hooks.has_pre());
assert!(!hooks.has_post());Fields§
§version: Option<String>Hook schema version.
pre: Option<Vec<CowHook>>Hooks executed before the settlement.
post: Option<Vec<CowHook>>Hooks executed after the settlement.
Implementations§
Source§impl OrderInteractionHooks
impl OrderInteractionHooks
Sourcepub fn new(pre: Vec<CowHook>, post: Vec<CowHook>) -> Self
pub fn new(pre: Vec<CowHook>, post: Vec<CowHook>) -> Self
Create hooks with the given pre- and post-execution lists.
Empty vectors are stored as None (omitted from JSON) rather than
as empty arrays, matching the TypeScript SDK’s behaviour.
§Parameters
pre— hooks to execute before the settlement trade.post— hooks to execute after the settlement trade.
§Returns
A new OrderInteractionHooks with version set to None.
§Example
use cow_app_data::{CowHook, OrderInteractionHooks};
let pre =
vec![CowHook::new("0x1234567890abcdef1234567890abcdef12345678", "0x095ea7b3", "50000")];
let hooks = OrderInteractionHooks::new(pre, vec![]);
assert!(hooks.has_pre());
assert!(!hooks.has_post());Sourcepub fn with_version(self, version: impl Into<String>) -> Self
pub fn with_version(self, version: impl Into<String>) -> Self
Trait Implementations§
Source§impl Clone for OrderInteractionHooks
impl Clone for OrderInteractionHooks
Source§fn clone(&self) -> OrderInteractionHooks
fn clone(&self) -> OrderInteractionHooks
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 OrderInteractionHooks
impl Debug for OrderInteractionHooks
Source§impl Default for OrderInteractionHooks
impl Default for OrderInteractionHooks
Source§fn default() -> OrderInteractionHooks
fn default() -> OrderInteractionHooks
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OrderInteractionHooks
impl<'de> Deserialize<'de> for OrderInteractionHooks
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
Auto Trait Implementations§
impl Freeze for OrderInteractionHooks
impl RefUnwindSafe for OrderInteractionHooks
impl Send for OrderInteractionHooks
impl Sync for OrderInteractionHooks
impl Unpin for OrderInteractionHooks
impl UnsafeUnpin for OrderInteractionHooks
impl UnwindSafe for OrderInteractionHooks
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