mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
utils_macros: Implement derive_control_flag
Add a new derive macro 'derive_control_flag' that is used in the next
commit to reimplement how the code deals with Secure Execution control
flags.
It implements Display, IntoEnumIterator and the ControlFlagTrait for
enums using unit variants only.
/// Trait for control flags that provide bit position information.
pub trait ControlFlagTrait {
/// Returns the bit position for this flag.
fn bit_position(self) -> u8;
}
Assisted-by: IBM Bob:1.0.4
Signed-off-by: Marc Hartmayer <marc@linux.ibm.com>
Reviewed-by: Steffen Eiden <seiden@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
committed by
Steffen Eiden
parent
618e22e38b
commit
2d330cd45f
@@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
//
|
||||
// Copyright IBM Corp.
|
||||
|
||||
//! Helper traits and utilities for testing the ControlFlag derive macro.
|
||||
|
||||
/// Trait for control flags that provide bit position information.
|
||||
pub trait ControlFlagTrait {
|
||||
/// Returns the bit position for this flag.
|
||||
fn bit_position(self) -> u8;
|
||||
}
|
||||
|
||||
/// Trait for enums that can be iterated over.
|
||||
pub trait IntoEnumIterator: Sized {
|
||||
/// Returns an iterator over all variants of the enum.
|
||||
fn iter() -> impl Iterator<Item = Self>;
|
||||
}
|
||||
Reference in New Issue
Block a user