1#![allow(incomplete_features)]
7#![feature(const_trait_impl)]
8#![feature(unsized_const_params)]
9#![feature(adt_const_params)]
10#![feature(default_field_values)]
11#![feature(const_heap)]
12#![feature(const_default)]
13#![feature(generic_const_exprs)]
14
15mod state;
17#[cfg(test)]
18mod tests;
19
20pub use state::{
22 Same,
23 Name
24};
25
26use state::{
28 State,
29 Main,
30 DerivedState
31};
32
33use libutils_issue::Issue;
35
36use libutils_terminal::TERMINAL;
38
39use libutils_threat::Threat;
41
42use libutils_console::{
44 Console,
45 Synchronization
46};
47
48
49pub struct Report<Current: State> {
55 data: Current
56}
57
58impl Report<Main> {
60 pub const fn new(name: &'static str) -> Self {
61 let mut chain = Vec::new();
62 chain.push(name);
63 return Self {
64 data: Main {
65 chain: chain
66 }
67 };
68 }
69}
70
71const impl Default for Report<Main> {
73 fn default() -> Self {return Self::new("Main")}
74}
75
76impl<Current: State> Report<Current> {
78 #[inline]
79 pub fn to<'valid, Following: DerivedState<'valid>>(&'valid mut self) -> Report<Following> {return Report {
80 data: Following::convert(&mut self.data)
81 }}
82 #[inline]
83 pub fn issue<Object: Into<Issue>, Type>(&self, object: Object) -> Option<Type> {
84 TERMINAL.problem(Threat {
85 issue: object.into(),
86 chain: self.data.chain()
87 }).sync();
88 return None;
89 }
90}