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
#[cfg(feature = "smallvec")]
pub(crate) type FieldSet = smallvec::SmallVec<[Field; 3]>;
#[cfg(not(feature = "smallvec"))]
pub(crate) type FieldSet = Vec<Field>;

/// A key-value pair recorded from trace data.
#[derive(Clone, Debug, Hash, PartialEq, Eq)]
pub struct Field {
    key: &'static str,
    value: String,
}

impl Field {
    pub(crate) fn new(key: &'static str, value: String) -> Self {
        Field { key, value }
    }

    /// Returns the field's key.
    pub fn key(&self) -> &'static str {
        self.key
    }

    /// Returns the field's value.
    pub fn value(&self) -> &str {
        &self.value
    }
}