impl Ord for Event

This commit is contained in:
Mike Dilger 2024-03-02 11:04:33 +13:00
parent 3a6f89649e
commit 8828074e7c

View File

@ -1,6 +1,7 @@
use super::{Id, Kind, Pubkey, Sig, Tags, Time};
use crate::error::{ChorusError, Error};
use crate::types::parse::json_escape::json_escape;
use std::cmp::Ordering;
use std::fmt;
mod json_event;
@ -178,6 +179,20 @@ impl fmt::Display for Event<'_> {
}
}
impl Eq for Event<'_> {}
impl PartialOrd for Event<'_> {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for Event<'_> {
fn cmp(&self, other: &Self) -> Ordering {
self.created_at().cmp(&other.created_at())
}
}
#[derive(Debug, Clone)]
pub struct OwnedEvent(pub Vec<u8>);