1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
mod domain;
pub use domain::*;
mod event;
pub use event::Event;
use std::cmp::Ordering;
#[derive(Clone, Eq, Debug)]
pub struct Record {
cpu: u16,
domain: Domain,
event: Event,
}
impl Record {
pub(crate) fn new(cpu: u16, domain: Domain, event: Event) -> Self {
Self { cpu, domain, event }
}
pub fn get_cpu(&self) -> u16 {
self.cpu
}
pub fn get_domain(&self) -> Domain {
self.domain
}
pub fn get_event(&self) -> Event {
self.event.clone()
}
}
impl PartialEq for Record {
fn eq(&self, other: &Self) -> bool {
self.cpu == other.cpu && self.domain == other.domain && self.event == other.event
}
}
impl Ord for Record {
fn cmp(&self, other: &Self) -> Ordering {
self.event.cmp(&other.event)
}
}
impl PartialOrd for Record {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn record() {
let domain = Domain::from_u32(0x00018000);
let event = Event::new(0x0001f003, 0, vec![]);
let record = Record::new(5, domain, event);
assert_eq!(record.get_cpu(), 5);
assert_eq!(record.get_domain(), domain);
assert_eq!(record.get_event(), Event::new(0x0001f003, 0, vec![]));
}
}