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
use crate::KeyValue;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::time::SystemTime;
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct Event {
pub name: String,
pub timestamp: SystemTime,
pub attributes: Vec<KeyValue>,
}
impl Event {
pub fn new(name: String, timestamp: SystemTime, attributes: Vec<KeyValue>) -> Self {
Event {
name,
timestamp,
attributes,
}
}
pub fn with_name(name: String) -> Self {
Event {
name,
timestamp: crate::time::now(),
attributes: Vec::new(),
}
}
}