use thiserror::Error;
#[derive(Debug, Error)]
pub enum Error {
#[error("Io error: {0}")]
Io(#[from] std::io::Error),
#[error("Json error: {0}")]
Json(#[from] serde_json::Error),
#[error("system clock is before the Unix epoch: {0}")]
SystemTime(#[from] std::time::SystemTimeError),
#[error("actor lifecycle queue is full")]
LifecycleQueueFull,
#[error("actor is closed")]
ActorClosed,
#[error("Salt not found")]
SaltNotFound,
#[error("Permissions not found")]
PermissionsNotFound,
#[error("Corrupted token")]
CorruptedToken,
#[error("Command {0}: should have AuthData ")]
CommandShouldHaveAuthData(&'static str),
#[error("Encryption failed")]
EncryptionFailed,
#[error("Response too large: {0} bytes")]
ResponseTooLarge(usize),
#[error("Command timed out")]
Timeout,
#[error("Connection closed")]
ConnectionClosed,
#[error("protocol error: {0}")]
Protocol(String),
#[error("Connection lost")]
ConnectionLost,
#[error("Invalid UTF-8 in command payload")]
InvalidUtf8,
#[error("no permission to execute `{command}` (requires {required}, but actor has {actual})")]
NoPermission {
command: &'static str,
required: crate::permission::PermissionLevel,
actual: crate::permission::PermissionLevel,
},
#[error("Device error: {code} - {msg} ({desc})")]
Device {
code: crate::response::ResponseCode,
msg: String,
desc: String,
},
}
pub type Result<T> = std::result::Result<T, Error>;