1mod config;
10mod error;
11mod lifecycle;
12mod plugin;
13mod request;
14
15pub use config::{PluginConfig, PluginMetadata};
16pub use error::{PluginError, PluginResult};
17pub use lifecycle::LifecycleState;
18pub use plugin::{Plugin, PluginContext, PluginFactory};
19pub use request::{RequestContext, ResponseBuilder};
20
21#[repr(u8)]
23#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
24pub enum LogLevel {
25 Trace = 0,
26 Debug = 1,
27 Info = 2,
28 Warn = 3,
29 Error = 4,
30 Off = 5,
31}
32
33impl LogLevel {
34 pub fn from_u8(value: u8) -> Self {
35 match value {
36 0 => LogLevel::Trace,
37 1 => LogLevel::Debug,
38 2 => LogLevel::Info,
39 3 => LogLevel::Warn,
40 4 => LogLevel::Error,
41 _ => LogLevel::Off,
42 }
43 }
44}
45
46impl std::fmt::Display for LogLevel {
47 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
48 match self {
49 LogLevel::Trace => write!(f, "TRACE"),
50 LogLevel::Debug => write!(f, "DEBUG"),
51 LogLevel::Info => write!(f, "INFO"),
52 LogLevel::Warn => write!(f, "WARN"),
53 LogLevel::Error => write!(f, "ERROR"),
54 LogLevel::Off => write!(f, "OFF"),
55 }
56 }
57}
58
59pub mod prelude {
61 pub use crate::{
62 LifecycleState, LogLevel, Plugin, PluginConfig, PluginContext, PluginError, PluginFactory,
63 PluginResult, RequestContext, ResponseBuilder,
64 };
65}
66
67#[cfg(test)]
68mod lib_tests;