use std::ffi::CStr;
use crate::bindings::plugin_abi::{PluginColor, PluginContext};
#[derive(Debug)]
pub struct PluginInfo {
name: &'static CStr,
log_name: &'static CStr,
dependency_name: &'static CStr,
context: PluginContext,
color: PluginColor,
}
impl PluginInfo {
pub const fn new(
name: &'static CStr,
log_name: &'static CStr,
dependency_name: &'static CStr,
context: PluginContext,
) -> Self {
assert!(name.to_bytes().len() > 1, "consider actually having a name");
assert!(
log_name.to_bytes().len() > 1,
"consider actually having a log_name"
);
assert!(
dependency_name.to_bytes().len() > 1,
"consider actually having a dependency_name"
);
assert!(log_name.to_bytes().len() == 9, "log name is used for logging and ideally should be 9 chars long and all upercase to look like every other log str");
Self {
name,
log_name,
dependency_name,
context,
color: PluginColor {
red: 244,
green: 106,
blue: 14,
},
}
}
pub const fn new_with_color(
name: &'static CStr,
log_name: &'static CStr,
dependency_name: &'static CStr,
context: PluginContext,
color: PluginColor,
) -> Self {
Self {
color,
..Self::new(name, log_name, dependency_name, context)
}
}
pub const fn get_name(&self) -> &'static CStr {
self.name
}
pub const fn get_log_name(&self) -> &'static CStr {
self.log_name
}
pub const fn get_dependency_name(&self) -> &'static CStr {
self.dependency_name
}
pub const fn get_context(&self) -> PluginContext {
self.context
}
pub const fn get_color(&self) -> PluginColor {
self.color
}
}