1use thiserror::Error;
2
3#[derive(Error, Debug)]
4pub enum Pop3Error {
5 #[error("Stream connection closed")]
6 ConnectionClosed,
7
8 #[error("Already authenticated")]
9 AlreadyAuthenticated,
10
11 #[error("IO: {0}")]
12 Io(#[from] std::io::Error),
13
14
15 #[error("Number parsing error: {0}")]
16 InvalidNumber(std::num::ParseIntError),
17
18 #[error("String parsing error: {0}")]
19 InvalidString(std::str::Utf8Error),
20
21 #[error("Invalid response")]
22 InvalidResponse,
23
24 #[error("Other error: {0}")]
25 OtherString(String),
26
27 }
35
36impl Pop3Error {
37 pub fn other<E: AsRef<str>>(err: E) -> Self {
38 Self::OtherString(err.as_ref().to_string())
39 }
40}