use snafu::prelude::*;

#[derive(Debug, Snafu)]
pub enum DecodeError {
    #[snafu(display("Unexpected end of input"))]
    UnexpectedEndOfInput,

    #[snafu(display("Malformed whisker at position `{}`", position))]
    MalformedWhisker { position: usize },

    #[snafu(display("Duplicate whisker at position `{}`", position))]
    DuplicateWhisker { position: usize },

    #[snafu(display("Comment data is not valid UTF-8"))]
    InvalidComment,

    #[snafu(display("CRC checksum mismatch"))]
    CrcMismatch,

    #[snafu(display("LDPC Decode error"))]
    LdpcError,

    #[snafu(display("Given data does not fit in the CATS packet"))]
    Overflow,
}

#[derive(Debug, Snafu)]
pub enum EncodeError {
    #[snafu(display("New data is a duplicate of an existing data"))]
    DuplicateData,

    #[snafu(display("Given data causes CATS packet to overflow"))]
    CatsOverflow,
}

#[derive(Debug, Snafu)]
pub enum CommentError {
    #[snafu(display("CATS packet does not have comment data"))]
    NoComment,

    #[snafu(display("Given buffer too small for comment data"))]
    BufferOverflow,
}