use std::io::Error as IoError;
use std::str::Utf8Error;
use base64::DecodeError;
pub type Result<T> = std::result::Result<T, Error>;
#[derive(thiserror::Error, Debug)]
#[non_exhaustive]
pub enum Error {
#[error("io: {0}")]
Io(#[from] IoError),
#[error("bad response: {0}")]
Bad(String),
#[error("no response: {0}")]
No(String),
#[error("connection lost")]
ConnectionLost,
#[error("parse: {0}")]
Parse(#[from] ParseError),
#[error("validate: {0}")]
Validate(#[from] ValidateError),
#[error("could not append mail to mailbox")]
Append,
}
#[derive(thiserror::Error, Debug)]
pub enum ParseError {
#[error("unable to parse status response")]
Invalid(Vec<u8>),
#[error("encountered unexpected parsed response: {0}")]
Unexpected(String),
#[error("unable to parse authentication response: {0} - {1:?}")]
Authentication(String, Option<DecodeError>),
#[error("unable to parse data ({0:?}) as UTF-8 text: {1:?}")]
DataNotUtf8(Vec<u8>, #[source] Utf8Error),
#[error("expected response not found for: {0}")]
ExpectedResponseNotFound(String),
}
#[derive(thiserror::Error, Debug)]
#[error("invalid character in input: '{0}'")]
pub struct ValidateError(pub char);
#[cfg(test)]
mod tests {
use super::*;
fn is_send<T: Send>(_t: T) {}
#[test]
fn test_send() {
is_send::<Result<usize>>(Ok(3));
}
}