rust_async_tuyapi/
error.rs

1use aes::cipher::InvalidLength;
2use inout::block_padding::UnpadError;
3use std::io;
4use std::str::Utf8Error;
5use thiserror::Error;
6
7#[derive(Error, Debug)]
8#[error("{0}")]
9pub enum ErrorKind {
10    Base64DecodeError(#[from] base64::DecodeError),
11    JsonError(#[from] serde_json::error::Error),
12    SystemTimeError(#[from] std::time::SystemTimeError),
13    TcpError(#[from] io::Error),
14    Utf8Error(#[from] Utf8Error),
15
16    InvalidKeyLength(#[from] InvalidLength),
17    UnpadError(#[from] UnpadError),
18
19    #[error("parsing failed with: {0:?}")]
20    ParseError(nom::error::ErrorKind),
21    #[error("Something went wrong when parsing the received buffer. It still contains data after parsing is done")]
22    BufferNotCompletelyParsedError,
23    #[error("Can not encode messages that are missing CommandType")]
24    CanNotEncodeMessageWithoutCommand,
25    #[error("No CommandType was supplied in message")]
26    CommandTypeMissing,
27    #[error("Error: CRC mismatch")]
28    CRCError,
29    #[error("Missing Tuya key")]
30    MissingKey,
31    #[error("The key length is {0}, should be 16")]
32    KeyLength(usize),
33    #[error("the tuyadevice is not created with a socket address. can not set object")]
34    MissingAddressError,
35    #[error("Data was incomplete. Error while parsing the received data")]
36    ParsingIncomplete,
37    #[error("Bad read from TcpStream")]
38    TcpStreamClosed,
39    #[error("The given version {0} is not valid")]
40    VersionError(String),
41    #[error("SessKeyNegResp message did not contain remote key")]
42    MissingRemoteKey,
43    #[error("SessKeyNegResp message does not contain a valid remote key")]
44    InvalidRemoteKey,
45    #[error("Not connected to device")]
46    NotConnected,
47}