@@ -7,8 +7,8 @@ use uefi_raw::Boolean;
77/// The UEFI boot policy is a property that influences the behaviour of
88/// various UEFI functions that load files (typically UEFI images).
99///
10- /// This type is not ABI compatible. On the ABI level, this is an UEFI
11- /// boolean .
10+ /// This type is not ABI compatible. On the ABI level, this corresponds to
11+ /// a [`Boolean`] .
1212#[ derive( Copy , Clone , Debug , Default , Eq , Ord , PartialEq , PartialOrd ) ]
1313pub enum BootPolicy {
1414 /// Indicates that the request originates from the boot manager, and that
@@ -17,16 +17,16 @@ pub enum BootPolicy {
1717 ///
1818 /// Boot selection refers to what a user has chosen in the (GUI) boot menu.
1919 ///
20- /// This corresponds to the `TRUE` value in the UEFI spec .
20+ /// This corresponds to the underlying [`Boolean`] being `true` .
2121 BootSelection ,
2222 /// The provided `file_path` must match an exact file to be loaded.
2323 ///
24- /// This corresponds to the `FALSE` value in the UEFI spec .
24+ /// This corresponds to the underlying [`Boolean`] being `false` .
2525 #[ default]
2626 ExactMatch ,
2727}
2828
29- impl From < BootPolicy > for bool {
29+ impl From < BootPolicy > for Boolean {
3030 fn from ( value : BootPolicy ) -> Self {
3131 match value {
3232 BootPolicy :: BootSelection => true . into ( ) ,
@@ -51,20 +51,15 @@ mod tests {
5151
5252 #[ test]
5353 fn boot_policy ( ) {
54- assert_eq ! ( bool :: from( BootPolicy :: ExactMatch ) , false ) ;
55- assert_eq ! ( bool :: from( BootPolicy :: BootSelection ) , true ) ;
56-
57- assert_eq ! ( BootPolicy :: from( false ) , BootPolicy :: ExactMatch ) ;
58- assert_eq ! ( BootPolicy :: from( true ) , BootPolicy :: BootSelection ) ;
59-
60- assert_eq ! ( u8 :: from( BootPolicy :: ExactMatch ) , 0 ) ;
61- assert_eq ! ( u8 :: from( BootPolicy :: BootSelection ) , 1 ) ;
62-
63- assert_eq ! ( BootPolicy :: try_from( 0 ) , Ok ( BootPolicy :: ExactMatch ) ) ;
64- assert_eq ! ( BootPolicy :: try_from( 1 ) , Ok ( BootPolicy :: BootSelection ) ) ;
6554 assert_eq ! (
66- BootPolicy :: try_from( 2 ) ,
67- Err ( BootPolicyError :: InvalidInteger ( 2 ) )
55+ BootPolicy :: try_from( Boolean :: TRUE ) . unwrap( ) ,
56+ BootPolicy :: BootSelection
57+ ) ;
58+ assert_eq ! (
59+ BootPolicy :: try_from( Boolean :: FALSE ) . unwrap( ) ,
60+ BootPolicy :: ExactMatch
6861 ) ;
62+ assert_eq ! ( Boolean :: from( BootPolicy :: BootSelection ) , Boolean :: TRUE ) ;
63+ assert_eq ! ( Boolean :: from( BootPolicy :: ExactMatch ) , Boolean :: FALSE ) ;
6964 }
7065}
0 commit comments