#[derive(Debug, Clone)]
pub struct SecretFieldInfo {
pub name: &'static str,
pub category: &'static str,
pub is_set: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PropKind {
String,
Bool,
Integer,
Float,
Enum,
}
pub trait HasPropKind {
const PROP_KIND: PropKind;
}
macro_rules! impl_prop_kind {
($kind:expr, $($ty:ty),+) => {
$(impl HasPropKind for $ty { const PROP_KIND: PropKind = $kind; })+
};
}
impl_prop_kind!(PropKind::Bool, bool);
impl_prop_kind!(PropKind::String, String);
impl_prop_kind!(PropKind::Float, f64, f32);
impl_prop_kind!(
PropKind::Integer,
u8,
u16,
u32,
u64,
usize,
i8,
i16,
i32,
i64,
isize
);
#[derive(Clone)]
pub struct PropFieldInfo {
pub name: &'static str,
pub category: &'static str,
pub display_value: String,
pub type_hint: &'static str,
pub kind: PropKind,
pub is_secret: bool,
pub enum_variants: Option<fn() -> Vec<String>>,
}
impl PropFieldInfo {
pub fn is_enum(&self) -> bool {
self.enum_variants.is_some()
}
}
impl std::fmt::Debug for PropFieldInfo {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("PropFieldInfo")
.field("name", &self.name)
.field("kind", &self.kind)
.field("is_secret", &self.is_secret)
.finish_non_exhaustive()
}
}
pub trait ChannelConfig {
fn name() -> &'static str;
fn desc() -> &'static str;
}
pub trait ConfigHandle {
fn name(&self) -> &'static str;
fn desc(&self) -> &'static str;
}