mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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>
18 lines
503 B
Rust
18 lines
503 B
Rust
// 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>;
|
|
}
|