use std::time::Duration;
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum ParseError {
#[error(
"use the primary iCloud address (@icloud.com, @me.com or @mac.com), not a custom domain"
)]
AppleId,
#[error("mailbox path is empty, a URL, or contains a control character")]
MailboxPath,
#[error("uid must be a non-zero IMAP identifier")]
Uid,
#[error("resource path must be relative to the collection, with no URL and no .. segment")]
ResourcePath,
#[error("etag is empty or contains a control character")]
ETag,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum IdError {
#[error("id could not be decoded")]
Decode,
}
#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
#[non_exhaustive]
pub enum CoreError {
#[error("authentication failed")]
Auth,
#[error("network error")]
Network,
#[error("protocol error")]
Protocol(String),
#[error("not found")]
NotFound,
#[error("conflict")]
Conflict,
#[error("forbidden")]
Forbidden,
#[error("rate limited")]
RateLimited {
retry_after: Option<Duration>,
},
#[error("unsupported: {0}")]
Unsupported(&'static str),
#[error("host not allowed")]
HostNotAllowed,
#[error("{0}")]
InvalidInput(String),
}
impl CoreError {
#[must_use]
pub fn protocol_detail(&self) -> Option<&str> {
match self {
Self::Protocol(detail) => Some(detail),
_ => None,
}
}
}