1use std::cmp::Ordering;
4
5use super::Order;
6
7#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
9pub struct Trade {
10 #[serde(skip_serializing_if = "Option::is_none")]
12 pub id: Option<i64>,
13 pub order: Order,
15 pub timestamp: u64,
17}
18
19impl PartialOrd for Trade {
20 fn partial_cmp(&self, other: &Trade) -> Option<Ordering> {
21 if self.timestamp > other.timestamp {
22 Some(Ordering::Greater)
23 } else if self.timestamp == other.timestamp {
24 Some(Ordering::Equal)
25 } else {
26 Some(Ordering::Less)
27 }
28 }
29}
30
31impl Ord for Trade {
32 fn cmp(&self, other: &Trade) -> Ordering {
33 self.partial_cmp(other).unwrap()
34 }
35}
36
37impl Eq for Trade {}