1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Error type

use core::fmt::{self, Display};

/// Error type
#[derive(Copy, Clone, Debug)]
pub enum Error {
    /// Value contains unnecessary leading zeroes
    LeadingZeroes,

    /// Value is truncated / malformed
    Truncated,
}

impl Display for Error {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str(match self {
            Error::LeadingZeroes => "leading zeroes in vint64 value",
            Error::Truncated => "truncated vint64 value",
        })
    }
}

#[cfg(feature = "std")]
impl std::error::Error for Error {}