1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
use core::convert::Infallible;

/// Enum of possible errors returned from packing functions
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Error {
    /// Pack or Unpack method called with a slice of insufficient length
    /// Check the `PACK_BYTES_LEN` on the struct impl 
    InsufficientBytes,

    /// Attempted to unpack an enum but the value found didn't match any
    /// known discriminants
    InvalidEnumDiscriminant,

    /// Can't actually be constructed as Infallible can never actually exist
    Infallible(Infallible),
}

impl From<Infallible> for Error {
    fn from(i: Infallible) -> Error {
        Error::Infallible(i)
    }
}