11use log:: { error, info, warn} ;
22use std:: fmt;
33
4+ /// CheckResultValue is the final value for the result of an individual check.
5+ ///
6+ /// Failed means a check ran successfully but did not pass. Errored means a check hit an
7+ /// error while executing.
8+ ///
9+ /// Failed and Errored should contain a descriptive string explaining the result.
410pub enum CheckResultValue {
511 Passed ,
612 Failed ( String ) ,
@@ -19,8 +25,13 @@ impl fmt::Display for CheckResultValue {
1925 }
2026}
2127
28+ /// CheckResult is the end result of an individual check. It carries the name of the individual
29+ /// check as well as the end result.
2230pub struct CheckResult {
31+ /// name is the name of the individual check
2332 pub name : String ,
33+
34+ /// result is the final result of an individual check
2435 pub result : CheckResultValue ,
2536}
2637
@@ -33,9 +44,17 @@ impl CheckResult {
3344 }
3445}
3546
47+ /// CheckGroupResult is the result for a top-level group of checks. The result field is calculated
48+ /// from the set of individual checks within that group.
3649pub struct CheckGroupResult {
50+ /// name is the name of the group of checks
3751 pub name : String ,
52+
53+ /// result is the top-level result of the group of checks. It is calculated from the results of
54+ /// each individual check.
3855 pub result : CheckResultValue ,
56+
57+ /// results is the list of results from each individual check within this group.
3958 pub results : Vec < CheckResult > ,
4059}
4160
@@ -47,6 +66,9 @@ impl CheckGroupResult {
4766 results : Vec :: new ( ) ,
4867 }
4968 }
69+
70+ /// log_group is a pretty-print helper to log the result of the group based on what the result
71+ /// value is.
5072 pub fn log_group ( & self ) {
5173 let name = & self . name ;
5274 let result = & self . result ;
@@ -59,6 +81,8 @@ impl CheckGroupResult {
5981 }
6082 }
6183
84+ /// log_individual_checks is a pretty-print helper to log the results of each individual check
85+ /// within a group.
6286 pub fn log_individual_checks ( & self ) {
6387 let group_name = & self . name ;
6488 for check_result in self . results . iter ( ) {
@@ -75,12 +99,22 @@ impl CheckGroupResult {
7599 }
76100}
77101
102+ /// CheckGroup is a trait representing a group of checks.
78103pub trait CheckGroup {
104+ /// name is the name of the check group
79105 fn name ( & self ) -> & str ;
106+
107+ /// id is the identifier for the check group. This field is used when skipping or selecting
108+ /// certain check groups to run so it should be env/cli friendly.
80109 fn id ( & self ) -> & str ;
110+
111+ /// description is a longer form text field explaining what this check group is intended for.
81112 fn description ( & self ) -> & str ;
113+
114+ /// run is the main entry point that runs the checks within the check group.
82115 fn run ( & self ) -> CheckGroupResult ;
83116}
84117
118+ // modules
85119pub mod script;
86120pub mod system;
0 commit comments