rust_tuyapi/
error.rs

1use openssl::error::ErrorStack;
2use std::io;
3use std::str::Utf8Error;
4use thiserror::Error;
5
6#[derive(Error, Debug)]
7#[error("{0}")]
8pub enum ErrorKind {
9    Base64DecodeError(#[from] base64::DecodeError),
10    JsonError(#[from] serde_json::error::Error),
11    OpenSSLError(#[from] ErrorStack),
12    SystemTimeError(#[from] std::time::SystemTimeError),
13    TcpError(#[from] io::Error),
14    Utf8Error(#[from] Utf8Error),
15
16    #[error("parsing failed with: {0:?}")]
17    ParseError(nom::error::ErrorKind),
18    #[error("Something went wrong when parsing the received buffer. It still contains data after parsing is done")]
19    BufferNotCompletelyParsedError,
20    #[error("Can not encode messages that are missing CommandType")]
21    CanNotEncodeMessageWithoutCommand,
22    #[error("No CommandType was supplied in message")]
23    CommandTypeMissing,
24    #[error("Error: CRC mismatch")]
25    CRCError,
26    #[error("The key length is {0}, should be 16")]
27    KeyLength(usize),
28    #[error("the tuyadevice is not created with a socket address. can not set object")]
29    MissingAddressError,
30    #[error("Data was incomplete. Error while parsing the received data")]
31    ParsingIncomplete,
32    #[error("Bad read from TcpStream")]
33    BadTcpRead,
34    #[error("Bad read from UdpSocket")]
35    BadUdpRead,
36    #[error("The given version {0}.{1} is not valid")]
37    VersionError(String, String),
38}