osquery_rust/plugin/table/
column_def.rs

1use strum_macros::Display;
2
3// ColumnDef defines a column used in a table plugin.
4// Prefer using the helper functions to create a ColumnDef.
5#[derive(Clone, Debug)]
6pub struct ColumnDef {
7    name: String,
8    t: ColumnType,
9}
10
11#[derive(Clone, Display, Debug)]
12#[strum(serialize_all = "UPPERCASE")]
13pub enum ColumnType {
14    // TEXT: containing strings
15    Text,
16    // INTEGER: containing integers
17    Integer,
18    // BIGINT: containing large integers
19    BigInt,
20    // DOUBLE: containing floating point values
21    Double,
22}
23
24impl ColumnDef {
25    pub fn new(name: &str, t: ColumnType) -> Self {
26        ColumnDef {
27            name: name.to_owned(),
28            t,
29        }
30    }
31
32    pub(crate) fn name(&self) -> String {
33        self.name.to_string()
34    }
35
36    pub(crate) fn t(&self) -> String {
37        self.t.to_string()
38    }
39}