@@ -4,28 +4,28 @@ use std::str::FromStr;
44pub enum ValidationError { }
55
66#[ derive( Debug , PartialEq , Eq , Hash , Clone ) ]
7- pub enum ValidationProfile {
7+ pub enum ValidationPreset {
88 Basic ,
99 Extended ,
1010 Full ,
1111}
1212
13- impl FromStr for ValidationProfile {
13+ impl FromStr for ValidationPreset {
1414 type Err = ( ) ;
1515
16- fn from_str ( input : & str ) -> Result < ValidationProfile , Self :: Err > {
16+ fn from_str ( input : & str ) -> Result < ValidationPreset , Self :: Err > {
1717 match input {
18- "basic" => Ok ( ValidationProfile :: Basic ) ,
19- "extended" => Ok ( ValidationProfile :: Extended ) ,
20- "full" => Ok ( ValidationProfile :: Full ) ,
18+ "basic" => Ok ( ValidationPreset :: Basic ) ,
19+ "extended" => Ok ( ValidationPreset :: Extended ) ,
20+ "full" => Ok ( ValidationPreset :: Full ) ,
2121 _ => Err ( ( ) ) ,
2222 }
2323 }
2424}
2525
2626pub trait Validate {
27- /// Validates this object according to a validation profile
28- fn validate_profile ( & ' static self , profile : ValidationProfile ) ;
27+ /// Validates this object according to a validation preset
28+ fn validate_preset ( & ' static self , preset : ValidationPreset ) ;
2929
3030 /// Validates this object according to a specific test ID.
3131 fn validate_by_test ( & self , version : & str ) ;
@@ -38,35 +38,35 @@ pub type Test<VersionedDocument> =
3838/// This trait MUST be implemented by the struct that represents a CSAF document
3939/// in the respective version.
4040///
41- /// It can then be used to validate documents with either [validate_by_profile ] or [validate_by_test].
41+ /// It can then be used to validate documents with either [validate_by_preset ] or [validate_by_test].
4242pub trait Validatable < VersionedDocument > {
43- /// Returns a hashmap containing the test ID per profile
44- fn profiles ( & self ) -> HashMap < ValidationProfile , Vec < & str > > ;
43+ /// Returns a hashmap containing the test ID per preset
44+ fn presets ( & self ) -> HashMap < ValidationPreset , Vec < & str > > ;
4545
4646 /// Returns a hashmap containing the test function per test ID
4747 fn tests ( & self ) -> HashMap < & str , Test < VersionedDocument > > ;
4848
4949 fn doc ( & self ) -> & VersionedDocument ;
5050}
5151
52- /// Executes all tests of the specified [profile ] against the [target]
52+ /// Executes all tests of the specified [preset ] against the [target]
5353/// (which is of type [VersionedDocument], e.g. a CSAF 2.0 document).
54- pub fn validate_by_profile < VersionedDocument > (
54+ pub fn validate_by_preset < VersionedDocument > (
5555 target : & impl Validatable < VersionedDocument > ,
56- profile : ValidationProfile ,
56+ preset : ValidationPreset ,
5757) {
58- println ! ( "Validating document with {:?} profile ... \n " , profile ) ;
58+ println ! ( "Validating document with {:?} preset ... \n " , preset ) ;
5959
6060 // Loop through tests
61- if let Some ( tests) = target. profiles ( ) . get ( & profile ) {
61+ if let Some ( tests) = target. presets ( ) . get ( & preset ) {
6262 for test_id in tests {
6363 println ! ( "Executing Test {}... " , test_id) ;
6464 validate_by_test ( target, test_id) ;
6565
6666 println ! ( )
6767 }
6868 } else {
69- println ! ( "No tests found for profile " )
69+ println ! ( "No tests found for preset " )
7070 }
7171}
7272
0 commit comments