falco_plugin/tables/import/
table_info.rs1use crate::tables::FieldTypeId;
2use num_traits::FromPrimitive;
3use std::fmt::Debug;
4
5#[repr(transparent)]
7pub struct TableInfo(falco_plugin_api::ss_plugin_table_info);
8
9impl Debug for TableInfo {
10 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
11 f.debug_struct("TableInfo")
12 .field("name", &self.name())
13 .field("key_type", &self.key_type())
14 .finish()
15 }
16}
17
18impl TableInfo {
19 pub fn name(&self) -> &str {
23 unsafe { std::ffi::CStr::from_ptr(self.0.name) }
24 .to_str()
25 .unwrap_or("<invalid table name>")
26 }
27
28 pub fn key_type(&self) -> Result<FieldTypeId, u32> {
33 match FieldTypeId::from_u32(self.0.key_type) {
34 Some(field_type) => Ok(field_type),
35 None => Err(self.0.key_type),
36 }
37 }
38}