#![allow(incomplete_features)]
#![feature(const_trait_impl)]
#![feature(unsized_const_params)]
#![feature(adt_const_params)]
#![feature(default_field_values)]
#![feature(generic_const_exprs)]
mod state;
#[cfg(test)]
mod tests;
pub use state::{
Add,
Stay
};
use state::{
State,
Main,
DerivedState
};
use libutils_issue::Issue;
use libutils_terminal::{
TERMINAL,
Console
};
use libutils_threat::{
Threat,
Severity
};
pub struct Report<Current: State> {
data: Current
}
impl Report<Main> {
pub fn new(name: &'static str) -> Self {Self {
data: Main {
chain: Vec::from([name])
}
}}
}
impl<Current: State> Report<Current> {
#[inline]
pub fn to<'valid, Following: DerivedState<'valid>>(&'valid mut self) -> Report<Following> {return Report {
data: Following::from(&mut self.data)
}}
#[inline]
pub fn warn<Object: Into<Issue>>(&self, object: Object) -> () {TERMINAL.write().problem(Threat {
object: object,
chain: self.data.chain(),
severity: Severity::Warning
})}
#[inline]
pub fn error<Object: Into<Issue>>(&self, object: Object) -> () {TERMINAL.write().problem(Threat {
object: object,
chain: self.data.chain(),
severity: Severity::Error
})}
#[inline]
pub fn critical<Object: Into<Issue>>(&self, object: Object) -> () {TERMINAL.write().problem(Threat {
object: object,
chain: self.data.chain(),
severity: Severity::Critical
})}
}