use core::fmt;
use crate::Flavor;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
BitLengthTooLarge {
bit_length: u32,
bits_precision: u32,
},
BitLengthTooSmall {
bit_length: u32,
flavor: Flavor,
},
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
match self {
Error::BitLengthTooLarge {
bit_length,
bits_precision,
} => write!(
f,
concat![
"The requested bit length of the candidate ({}) ",
"is larger than the maximum size of the target integer type ({})."
],
bit_length, bits_precision
),
Error::BitLengthTooSmall { bit_length, flavor } => write!(
f,
concat![
"The requested bit length of the candidate ({}) ",
"is too small to fit a prime of the flavor {:?}",
],
bit_length, flavor
),
}
}
}