falco_plugin/plugin/tables/
runtime.rs

1use crate::plugin::tables::table::raw::RawTable;
2use crate::plugin::tables::traits::TableMetadata;
3use crate::tables::TablesInput;
4use std::marker::PhantomData;
5
6/// A table entry with no predefined fields
7///
8/// It takes a tag struct as a type to distinguish between entries from different
9/// tables at compile time (runtime checks are also done on a best-effort basis)
10pub type RuntimeEntry<T> = super::entry::Entry<NoMetadata<T>>;
11
12#[derive(Debug)]
13pub struct NoMetadata<T> {
14    tag: PhantomData<T>,
15}
16
17impl<T> Clone for NoMetadata<T> {
18    fn clone(&self) -> Self {
19        Self { tag: PhantomData }
20    }
21}
22
23impl<T> TableMetadata for NoMetadata<T> {
24    fn new(_raw_table: &RawTable, _tables_input: &TablesInput) -> Result<Self, anyhow::Error> {
25        Ok(Self { tag: PhantomData })
26    }
27}
28
29impl<'a, T, U> From<&'a NoMetadata<T>> for NoMetadata<U> {
30    fn from(_value: &'a NoMetadata<T>) -> Self {
31        Self { tag: PhantomData }
32    }
33}
34
35impl<'a, T> From<&'a NoMetadata<T>> for () {
36    fn from(_value: &'a NoMetadata<T>) -> Self {}
37}