Skip to main content

active_reporting/
mod.rs

1//^
2//^ HEAD
3//^
4
5//> HEAD -> DOCS
6#![doc = include_str!("README.md")]
7
8//> HEAD -> LINTS
9#![allow(incomplete_features)]
10
11//> HEAD -> FEATURES
12#![feature(const_trait_impl)]
13#![feature(unsized_const_params)]
14#![feature(adt_const_params)]
15#![feature(default_field_values)]
16#![feature(const_heap)]
17#![feature(const_default)]
18#![feature(never_type)]
19#![feature(generic_const_exprs)]
20
21//> HEAD -> MODULES
22mod state;
23
24//> HEAD -> PUBLIC STATE
25pub use state::{
26    Same,
27    Name
28};
29
30//> HEAD -> STATE
31use state::{
32    State,
33    Main,
34    DerivedState
35};
36
37//> HEAD -> ISSUING
38use issuing::Issue;
39
40//> HEAD -> SYSTEMSTD
41use systemstd::System;
42
43//> HEAD -> SYSTEMIO
44use systemio::{
45    SystemIO, 
46    Update
47};
48
49
50//^ 
51//^ REPORT
52//^ 
53
54//> REPORT -> STRUCT
55pub struct Report<Current: State> {
56    data: Current
57}
58
59//> REPORT -> MAIN IMPLEMENTATION
60impl Report<Main> {
61    pub const fn new(name: &'static str) -> Self {
62        let mut chain = Vec::new();
63        chain.push(name);
64        return Self {
65            data: Main {
66                chain: chain
67            }
68        };
69    }
70}
71
72//> REPORT -> IMPLEMENTATION
73impl<Current: const State> Report<Current> {
74    pub const fn to<'valid, Following: const DerivedState<'valid>>(&'valid mut self) -> Report<Following> {
75        return Report {
76            data: Following::convert(&mut self.data)
77        }
78    }
79    pub fn issue(&self, object: impl Into<Issue>) -> Option<!> {
80        System::problem(object.into(), self.data.get()).sync();
81        return None;
82    }
83    pub fn eat<Type>(&self, result: Result<Type, Issue>) -> Option<Type> {return match result {
84        Ok(value) => Some(value),
85        Err(issue) => self.issue(issue)?
86    }}
87}
88
89//> REPORT -> DEFAULT
90const impl Default for Report<Main> {
91    fn default() -> Self {return Self::new("Main")}
92}