eldritchwire 0.2.4

A Rust crate for working with the Black Magic Design SDI camera control protocol.
Documentation
use std::fmt;

#[derive(Clone, Debug, PartialEq)]
pub enum EldritchError {
    DataOutOfBounds,
    EndOfPacket,
    InvalidCommandData { message: String, data: Vec<u8> },
    InvalidDataType { expected: String, command: String },
    InvalidHeader,
    PacketToLarge,
    PaddingViolation(String),
}

impl fmt::Display for EldritchError {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            EldritchError::DataOutOfBounds => write!(
                f,
                "A Data element is out of bounds for the specified command"
            ),
            EldritchError::EndOfPacket => {
                write!(f, "Attempting to retrieve more data at the end of packet")
            }
            EldritchError::PacketToLarge => write!(f, "Blanking packet is larger then 255 bytes"),
            EldritchError::InvalidCommandData{ message, data } => write!(f, "Invalid Command Data. \n {message}, data:\n\t{data:?}"),
            EldritchError::InvalidDataType{ expected, command  }=> write!(f, "Data type provided does not match command. Command: {command} Expected: {expected}"),
            EldritchError::InvalidHeader => write!(f, "Command Header is invlid"),
            EldritchError::PaddingViolation(msg) => write!(f, "{}", msg),
        }
    }
}

//     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
//         write!(f, "{{ file: {}, line: {} }}", file!(), line!())
//     }
// }