decode shows warnings on corrupted frames.

Closes #27.
This commit is contained in:
Alex Helfet 2017-12-31 16:16:46 +00:00
commit 3b87f4e94e

View file

@ -40,6 +40,21 @@ pub enum Error {
Ssmarshal(ssmarshal::Error),
}
impl Error {
/// Returns true if the error represents a corrupted frame. Data
/// may have been lost but the decoder should decode the next
/// frame correctly.
pub fn is_corrupt_frame(&self) -> bool {
match *self {
Error::ChecksumError |
Error::CobsDecodeFailed |
Error::EofDuringFrame
=> true,
_ => false,
}
}
}
#[cfg(feature = "use_std")]
impl From<io::Error> for Error {
fn from(e: io::Error) -> Error {