use std::cmp::Ordering;
use super::Order;
#[derive(Serialize, Deserialize, PartialEq, Clone, Debug)]
pub struct Trade {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<i64>,
pub order: Order,
pub timestamp: u64,
}
impl PartialOrd for Trade {
fn partial_cmp(&self, other: &Trade) -> Option<Ordering> {
if self.timestamp > other.timestamp {
Some(Ordering::Greater)
} else if self.timestamp == other.timestamp {
Some(Ordering::Equal)
} else {
Some(Ordering::Less)
}
}
}
impl Ord for Trade {
fn cmp(&self, other: &Trade) -> Ordering {
self.partial_cmp(other).unwrap()
}
}
impl Eq for Trade {}