1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use std::io::Error as IoError;
use std::result;
use std::str::Utf8Error;
use base64::DecodeError;
pub type Result<T> = 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("async_native_tls: {0}")]
NativeTlsError(#[from] async_native_tls::Error),
#[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),
}
#[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));
}
}