pub type MqttResult<T> = Result<T, MqttError>;
#[derive(Debug, thiserror::Error, uniffi::Error)]
#[uniffi(flat_error)]
pub enum MqttError {
#[error("malformed packet: {0}")]
MalformedPacket(String),
#[error("protocol error: {0}")]
Protocol(String),
#[error("io error: {0}")]
Io(String),
#[error("connection refused: {0}")]
ConnectionRefused(String),
#[error("not connected")]
NotConnected,
#[error("already connected")]
AlreadyConnected,
#[error("operation timed out")]
Timeout,
#[error("session error: {0}")]
Session(String),
}
impl From<std::io::Error> for MqttError {
fn from(e: std::io::Error) -> Self {
MqttError::Io(e.to_string())
}
}