falco_plugin/tables/import/
runtime.rs

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