26 lines
614 B
Rust
26 lines
614 B
Rust
use kaptan_config_derive::{Config, ConfigEnum};
|
|
|
|
#[derive(Clone, Copy, ConfigEnum)]
|
|
#[repr(u8)]
|
|
enum Mode {
|
|
Safe = 1,
|
|
#[config_enum(label = "Full authority")]
|
|
FullAuthority = 7,
|
|
}
|
|
|
|
#[derive(Config)]
|
|
struct EnumConfig {
|
|
#[config(enum, id = 1, key = "mode", unit = "mode")]
|
|
mode: Mode,
|
|
}
|
|
|
|
fn main() {
|
|
assert_eq!(Mode::Safe.wire_value(), 1);
|
|
assert!(matches!(Mode::try_from_wire(7), Some(Mode::FullAuthority)));
|
|
assert_eq!(Mode::CONFIG_ENUM_OPTIONS[1], (7, "Full authority"));
|
|
assert_eq!(
|
|
EnumConfig::DESCRIPTORS[0].enum_options,
|
|
Mode::CONFIG_ENUM_OPTIONS
|
|
);
|
|
}
|