keyfork mnemonic generate: impl ValueEnum for SeedSize
This commit is contained in:
parent
5d5d5181b3
commit
64c5c648a6
|
@ -1,5 +1,5 @@
|
|||
use super::Keyfork;
|
||||
use clap::{Parser, Subcommand, ValueEnum};
|
||||
use clap::{Parser, Subcommand, ValueEnum, builder::PossibleValue};
|
||||
use std::fmt::Display;
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
|
@ -10,6 +10,20 @@ pub enum SeedSize {
|
|||
Bits256,
|
||||
}
|
||||
|
||||
// custom impl to override names in ValueEnum
|
||||
impl ValueEnum for SeedSize {
|
||||
fn value_variants<'a>() -> &'a [Self] {
|
||||
&[Self::Bits128, Self::Bits256]
|
||||
}
|
||||
|
||||
fn to_possible_value(&self) -> Option<PossibleValue> {
|
||||
Some(PossibleValue::new(match self {
|
||||
SeedSize::Bits128 => "128",
|
||||
SeedSize::Bits256 => "256",
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(thiserror::Error, Debug, Clone)]
|
||||
pub enum SeedSizeError {
|
||||
#[error("Expected one of 128, 256")]
|
||||
|
|
Loading…
Reference in New Issue