use std::ops::RangeInclusive; use chrono::{DateTime, FixedOffset}; use super::bytes::Bytes; pub type Atom = Bytes; #[derive(Clone, Debug)] pub struct Tag(pub Bytes); #[derive(Debug)] #[non_exhaustive] pub enum Response { Capabilities(Vec), Continue(ResponseText), Condition(Condition), Done(ResponseDone), MailboxData(MailboxData), Fetch(u32, Vec), Expunge(u32), Fatal(Condition), Tagged(Tag, Condition), } #[derive(Debug)] pub struct ResponseText { pub code: Option, pub info: Bytes, } #[derive(Debug)] pub enum MessageAttribute { BodySection, BodyStructure, Envelope(Envelope), Flags(Vec), InternalDate(DateTime), ModSeq(u64), // RFC 4551, section 3.3.2 Rfc822(Option), Rfc822Header(Option), Rfc822Size(u32), Rfc822Text(Option), Uid(u32), } #[derive(Debug)] pub struct Envelope { pub date: Option, pub subject: Option, pub from: Option>, pub sender: Option>, pub reply_to: Option>, pub to: Option>, pub cc: Option>, pub bcc: Option>, pub in_reply_to: Option, pub message_id: Option, } #[derive(Debug)] pub struct Address { pub name: Option, pub adl: Option, pub mailbox: Option, pub host: Option, } #[derive(Debug)] pub struct ResponseDone { pub tag: Tag, pub status: Status, pub code: Option, pub info: Option, } #[derive(Debug)] pub struct Condition { pub status: Status, pub code: Option, pub info: Bytes, } #[derive(Debug)] pub enum Status { Ok, No, Bad, PreAuth, Bye, } #[derive(Debug)] #[non_exhaustive] pub enum ResponseCode { Alert, BadCharset(Option>), Capabilities(Vec), HighestModSeq(u64), // RFC 4551, section 3.1.1 Parse, PermanentFlags(Vec), ReadOnly, ReadWrite, TryCreate, UidNext(u32), UidValidity(u32), Unseen(u32), AppendUid(u32, Vec), CopyUid(u32, Vec, Vec), UidNotSticky, Other(Bytes, Option), } #[derive(Debug)] pub enum UidSetMember { UidRange(RangeInclusive), Uid(u32), } #[derive(Debug, PartialEq, Eq)] pub enum Capability { Imap4rev1, Auth(Atom), Atom(Atom), } #[derive(Debug)] pub enum MailboxData { Flags(Vec), List(MailboxList), Lsub, Search(Vec), Status, Exists(u32), Recent(u32), } #[derive(Debug)] pub enum Mailbox { Inbox, Name(Bytes), } #[derive(Debug)] pub enum Flag { Answered, Flagged, Deleted, Seen, Draft, Recent, Keyword(Atom), Extension(Atom), } #[derive(Debug)] pub struct MailboxList { pub flags: Vec, pub delimiter: Option, pub mailbox: Mailbox, } #[derive(Debug)] pub enum MailboxListFlag { NoInferiors, NoSelect, Marked, Unmarked, Extension(Atom), }