diff --git a/src/conversion_error.rs b/src/conversion_error.rs index 85a136d..fe73ed8 100644 --- a/src/conversion_error.rs +++ b/src/conversion_error.rs @@ -7,11 +7,17 @@ use weave::Error; #[derive(Copy, Clone, Eq, PartialEq)] pub enum ConversionError { + /// A corruption of the binary data has been detected. + CorruptionDetected, + + /// An invalid value was detected. + InvalidValue, + /// There were not enough bytes to create the desired type. TooFewBytes, /// There were to many bytes to create the desired type. - TooManyBytes + TooManyBytes, } @@ -22,6 +28,16 @@ impl Error for ConversionError { match *self { + ConversionError::CorruptionDetected => + { + "A corruption of the byte data was detected." + } + + ConversionError::InvalidValue => + { + "An invalid value was transmuted from the given byte data." + } + ConversionError::TooFewBytes => { "Not enough bytes of data were provided \ @@ -62,6 +78,16 @@ impl ::std::fmt::Display for ConversionError { match *self { + ConversionError::CorruptionDetected => + { + write!(f, "Byte Conversion Error: CorruptionDetected") + } + + ConversionError::InvalidValue => + { + write!(f, "Byte Conversion Error: InvalidValue") + } + ConversionError::TooFewBytes => { write!(f, "Byte Conversion Error: TooFewBytes")