hopr_transport_mixer/
data.rs1use std::cmp::Ordering;
2
3pub struct DelayedData<T> {
8 pub release_at: std::time::Instant,
9 pub item: T,
10}
11
12impl<T> PartialEq for DelayedData<T> {
13 fn eq(&self, other: &Self) -> bool {
14 self.release_at == other.release_at
15 }
16}
17
18impl<T> PartialOrd for DelayedData<T> {
19 fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
20 Some(self.cmp(other))
21 }
22}
23
24impl<T> Eq for DelayedData<T> {}
25
26impl<T> Ord for DelayedData<T> {
27 fn cmp(&self, other: &Self) -> Ordering {
28 self.release_at.cmp(&other.release_at)
29 }
30}
31
32impl<T> From<(std::time::Instant, T)> for DelayedData<T> {
33 fn from(value: (std::time::Instant, T)) -> Self {
34 Self {
35 release_at: value.0,
36 item: value.1,
37 }
38 }
39}