validators/errors/
unsigned_integer.rs1use core::{
2 fmt::{self, Display, Formatter},
3 num::ParseIntError,
4};
5#[cfg(feature = "std")]
6use std::error::Error;
7
8#[derive(Debug, Clone)]
10pub enum UnsignedIntegerError {
11 ParseIntError(ParseIntError),
12 TooLarge,
13 TooSmall,
14 Forbidden,
15}
16
17impl From<ParseIntError> for UnsignedIntegerError {
18 #[inline]
19 fn from(error: ParseIntError) -> Self {
20 Self::ParseIntError(error)
21 }
22}
23
24impl Display for UnsignedIntegerError {
25 #[inline]
26 fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> {
27 match self {
28 Self::ParseIntError(error) => Display::fmt(error, f),
29 Self::TooLarge => f.write_str("integer is too large"),
30 Self::TooSmall => f.write_str("integer is too small"),
31 Self::Forbidden => f.write_str("integer is forbidden"),
32 }
33 }
34}
35
36#[cfg(feature = "std")]
37impl Error for UnsignedIntegerError {}