2021-08-08 02:17:36 +00:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
2021-08-08 23:37:03 +00:00
|
|
|
pub type Atom<'a> = Cow<'a, [u8]>;
|
|
|
|
pub type CowU8<'a> = Cow<'a, [u8]>;
|
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Clone, Debug)]
|
2021-08-08 23:37:03 +00:00
|
|
|
pub struct Tag<'a>(pub CowU8<'a>);
|
2021-08-08 02:17:36 +00:00
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Debug)]
|
2021-08-08 19:31:18 +00:00
|
|
|
#[non_exhaustive]
|
2021-08-08 02:17:36 +00:00
|
|
|
pub enum Response<'a> {
|
2021-08-08 23:37:03 +00:00
|
|
|
Capabilities(Vec<Capability<'a>>),
|
|
|
|
Continue(ResponseText<'a>),
|
|
|
|
Condition(Condition<'a>),
|
2021-08-08 02:17:36 +00:00
|
|
|
Done(ResponseDone<'a>),
|
2021-08-08 23:37:03 +00:00
|
|
|
MailboxData(MailboxData<'a>),
|
|
|
|
Fetch(u32, Vec<MessageAttribute<'a>>),
|
|
|
|
Expunge(u32),
|
|
|
|
Fatal(Condition<'a>),
|
|
|
|
Tagged(Tag<'a>, Condition<'a>),
|
2021-08-08 02:17:36 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 23:37:03 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct ResponseText<'a> {
|
|
|
|
pub code: Option<ResponseCode<'a>>,
|
|
|
|
pub info: CowU8<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum MessageAttribute<'a> {
|
|
|
|
Flags(Vec<Flag<'a>>),
|
|
|
|
Envelope(Envelope),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Envelope {}
|
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Debug)]
|
2021-08-08 02:17:36 +00:00
|
|
|
pub struct ResponseDone<'a> {
|
2021-08-08 23:37:03 +00:00
|
|
|
pub tag: Tag<'a>,
|
2021-08-08 02:17:36 +00:00
|
|
|
pub status: Status,
|
|
|
|
pub code: Option<ResponseCode<'a>>,
|
|
|
|
pub info: Option<Cow<'a, str>>,
|
|
|
|
}
|
|
|
|
|
2021-08-08 19:31:18 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct Condition<'a> {
|
|
|
|
pub status: Status,
|
|
|
|
pub code: Option<ResponseCode<'a>>,
|
2021-08-08 23:37:03 +00:00
|
|
|
pub info: CowU8<'a>,
|
2021-08-08 19:31:18 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Debug)]
|
2021-08-08 02:17:36 +00:00
|
|
|
pub enum Status {
|
|
|
|
Ok,
|
|
|
|
No,
|
|
|
|
Bad,
|
|
|
|
PreAuth,
|
|
|
|
Bye,
|
|
|
|
}
|
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Debug)]
|
2021-08-08 19:31:18 +00:00
|
|
|
#[non_exhaustive]
|
2021-08-08 02:17:36 +00:00
|
|
|
pub enum ResponseCode<'a> {
|
2021-08-08 03:26:42 +00:00
|
|
|
Alert,
|
2021-08-08 02:17:36 +00:00
|
|
|
Capabilities(Vec<Capability<'a>>),
|
|
|
|
}
|
|
|
|
|
2021-08-08 05:54:01 +00:00
|
|
|
#[derive(Debug)]
|
2021-08-08 02:17:36 +00:00
|
|
|
pub enum Capability<'a> {
|
|
|
|
Imap4rev1,
|
2021-08-08 23:37:03 +00:00
|
|
|
Auth(Atom<'a>),
|
|
|
|
Atom(Atom<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum MailboxData<'a> {
|
|
|
|
Flags(Vec<Flag<'a>>),
|
|
|
|
List(MailboxList<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Mailbox<'a> {
|
|
|
|
Inbox,
|
|
|
|
Name(CowU8<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum Flag<'a> {
|
|
|
|
Answered,
|
|
|
|
Flagged,
|
|
|
|
Deleted,
|
|
|
|
Seen,
|
|
|
|
Draft,
|
|
|
|
Recent,
|
|
|
|
Keyword(Atom<'a>),
|
|
|
|
Extension(Atom<'a>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct MailboxList<'a> {
|
|
|
|
pub flags: Vec<MailboxListFlag<'a>>,
|
|
|
|
pub delimiter: Option<u8>,
|
|
|
|
pub mailbox: Mailbox<'a>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum MailboxListFlag<'a> {
|
|
|
|
NoInferiors,
|
|
|
|
NoSelect,
|
|
|
|
Marked,
|
|
|
|
Unmarked,
|
|
|
|
Extension(Atom<'a>),
|
2021-08-08 02:17:36 +00:00
|
|
|
}
|