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
use crate::KeyValue;
#[cfg(feature = "serialize")]
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
use std::time::SystemTime;
#[cfg_attr(feature = "serialize", derive(Deserialize, Serialize))]
#[derive(Clone, Debug, PartialEq)]
pub struct Event {
pub name: Cow<'static, str>,
pub timestamp: SystemTime,
pub attributes: Vec<KeyValue>,
pub dropped_attributes_count: u32,
}
impl Event {
pub fn new<T: Into<Cow<'static, str>>>(
name: T,
timestamp: SystemTime,
attributes: Vec<KeyValue>,
dropped_attributes_count: u32,
) -> Self {
Event {
name: name.into(),
timestamp,
attributes,
dropped_attributes_count,
}
}
pub fn with_name<T: Into<Cow<'static, str>>>(name: T) -> Self {
Event {
name: name.into(),
timestamp: crate::time::now(),
attributes: Vec::new(),
dropped_attributes_count: 0,
}
}
}