Migration implementation (part 1)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "imap_proto"
|
||||
version = "0.14.1"
|
||||
version = "0.15.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -53,6 +53,9 @@ impl Request<Command> {
|
||||
"\\Sent" => Some(Attribute::Sent),
|
||||
"\\Trash" => Some(Attribute::Trash),
|
||||
"\\Important" => Some(Attribute::Important),
|
||||
"\\Memos" => Some(Attribute::Memos),
|
||||
"\\Scheduled" => Some(Attribute::Scheduled),
|
||||
"\\Snoozed" => Some(Attribute::Snoozed),
|
||||
"\\All" => None,
|
||||
);
|
||||
|
||||
|
||||
@@ -106,6 +106,23 @@ impl Flag {
|
||||
"$NotJunk" => Flag::NotJunk,
|
||||
"$Phishing" => Flag::Phishing,
|
||||
"$Important" => Flag::Important,
|
||||
"$autosent" => Flag::Autosent,
|
||||
"$canunsubscribe" => Flag::CanUnsubscribe,
|
||||
"$followed" => Flag::Followed,
|
||||
"$hasattachment" => Flag::HasAttachment,
|
||||
"$hasmemo" => Flag::HasMemo,
|
||||
"$hasnoattachment" => Flag::HasNoAttachment,
|
||||
"$imported" => Flag::Imported,
|
||||
"$istrusted" => Flag::IsTrusted,
|
||||
"$MailFlagBit0" => Flag::MailFlagBit0,
|
||||
"$MailFlagBit1" => Flag::MailFlagBit1,
|
||||
"$MailFlagBit2" => Flag::MailFlagBit2,
|
||||
"$maskedemail" => Flag::MaskedEmail,
|
||||
"$memo" => Flag::Memo,
|
||||
"$muted" => Flag::Muted,
|
||||
"$new" => Flag::New,
|
||||
"$notify" => Flag::Notify,
|
||||
"$unsubscribed" => Flag::Unsubscribed,
|
||||
);
|
||||
|
||||
if let Some(flag) = flag {
|
||||
@@ -135,6 +152,23 @@ impl Flag {
|
||||
"$deleted" => Flag::Deleted,
|
||||
"$forwarded" => Flag::Forwarded,
|
||||
"$mdnsent" => Flag::MDNSent,
|
||||
"$autosent" => Flag::Autosent,
|
||||
"$canunsubscribe" => Flag::CanUnsubscribe,
|
||||
"$followed" => Flag::Followed,
|
||||
"$hasattachment" => Flag::HasAttachment,
|
||||
"$hasmemo" => Flag::HasMemo,
|
||||
"$hasnoattachment" => Flag::HasNoAttachment,
|
||||
"$imported" => Flag::Imported,
|
||||
"$istrusted" => Flag::IsTrusted,
|
||||
"$MailFlagBit0" => Flag::MailFlagBit0,
|
||||
"$MailFlagBit1" => Flag::MailFlagBit1,
|
||||
"$MailFlagBit2" => Flag::MailFlagBit2,
|
||||
"$maskedemail" => Flag::MaskedEmail,
|
||||
"$memo" => Flag::Memo,
|
||||
"$muted" => Flag::Muted,
|
||||
"$new" => Flag::New,
|
||||
"$notify" => Flag::Notify,
|
||||
"$unsubscribed" => Flag::Unsubscribed,
|
||||
)
|
||||
.unwrap_or_else(|| Flag::Keyword(value.into_boxed_str()))
|
||||
} else {
|
||||
|
||||
@@ -71,6 +71,9 @@ pub enum Attribute {
|
||||
Sent,
|
||||
Trash,
|
||||
Important,
|
||||
Memos,
|
||||
Scheduled,
|
||||
Snoozed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -142,6 +145,9 @@ impl Attribute {
|
||||
Attribute::Sent => b"\\Sent",
|
||||
Attribute::Trash => b"\\Trash",
|
||||
Attribute::Important => b"\\Important",
|
||||
Attribute::Memos => b"\\Memos",
|
||||
Attribute::Scheduled => b"\\Scheduled",
|
||||
Attribute::Snoozed => b"\\Snoozed",
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -157,6 +163,9 @@ impl TryFrom<&str> for Attribute {
|
||||
"sent" => Attribute::Sent,
|
||||
"trash" => Attribute::Trash,
|
||||
"important" => Attribute::Important,
|
||||
"memos" => Attribute::Memos,
|
||||
"scheduled" => Attribute::Scheduled,
|
||||
"snoozed" => Attribute::Snoozed,
|
||||
)
|
||||
.ok_or(())
|
||||
}
|
||||
|
||||
@@ -246,6 +246,23 @@ pub enum Flag {
|
||||
Deleted,
|
||||
Forwarded,
|
||||
MDNSent,
|
||||
Autosent,
|
||||
CanUnsubscribe,
|
||||
Followed,
|
||||
HasAttachment,
|
||||
HasMemo,
|
||||
HasNoAttachment,
|
||||
Imported,
|
||||
IsTrusted,
|
||||
MailFlagBit0,
|
||||
MailFlagBit1,
|
||||
MailFlagBit2,
|
||||
MaskedEmail,
|
||||
Memo,
|
||||
Muted,
|
||||
New,
|
||||
Notify,
|
||||
Unsubscribed,
|
||||
Keyword(Box<str>),
|
||||
}
|
||||
|
||||
@@ -264,6 +281,23 @@ impl Flag {
|
||||
Flag::Deleted => b"\\Deleted",
|
||||
Flag::Forwarded => b"$Forwarded",
|
||||
Flag::MDNSent => b"$MDNSent",
|
||||
Flag::Autosent => b"$autosent",
|
||||
Flag::CanUnsubscribe => b"$canunsubscribe",
|
||||
Flag::Followed => b"$followed",
|
||||
Flag::HasAttachment => b"$hasattachment",
|
||||
Flag::HasMemo => b"$hasmemo",
|
||||
Flag::HasNoAttachment => b"$hasnoattachment",
|
||||
Flag::Imported => b"$imported",
|
||||
Flag::IsTrusted => b"$istrusted",
|
||||
Flag::MailFlagBit0 => b"$MailFlagBit0",
|
||||
Flag::MailFlagBit1 => b"$MailFlagBit1",
|
||||
Flag::MailFlagBit2 => b"$MailFlagBit2",
|
||||
Flag::MaskedEmail => b"$maskedemail",
|
||||
Flag::Memo => b"$memo",
|
||||
Flag::Muted => b"$muted",
|
||||
Flag::New => b"$new",
|
||||
Flag::Notify => b"$notify",
|
||||
Flag::Unsubscribed => b"$unsubscribed",
|
||||
Flag::Keyword(keyword) => keyword.as_bytes(),
|
||||
});
|
||||
}
|
||||
@@ -284,6 +318,23 @@ impl From<Keyword> for Flag {
|
||||
Keyword::Deleted => Flag::Deleted,
|
||||
Keyword::Forwarded => Flag::Forwarded,
|
||||
Keyword::MdnSent => Flag::MDNSent,
|
||||
Keyword::Autosent => Flag::Autosent,
|
||||
Keyword::CanUnsubscribe => Flag::CanUnsubscribe,
|
||||
Keyword::Followed => Flag::Followed,
|
||||
Keyword::HasAttachment => Flag::HasAttachment,
|
||||
Keyword::HasMemo => Flag::HasMemo,
|
||||
Keyword::HasNoAttachment => Flag::HasNoAttachment,
|
||||
Keyword::Imported => Flag::Imported,
|
||||
Keyword::IsTrusted => Flag::IsTrusted,
|
||||
Keyword::MailFlagBit0 => Flag::MailFlagBit0,
|
||||
Keyword::MailFlagBit1 => Flag::MailFlagBit1,
|
||||
Keyword::MailFlagBit2 => Flag::MailFlagBit2,
|
||||
Keyword::MaskedEmail => Flag::MaskedEmail,
|
||||
Keyword::Memo => Flag::Memo,
|
||||
Keyword::Muted => Flag::Muted,
|
||||
Keyword::New => Flag::New,
|
||||
Keyword::Notify => Flag::Notify,
|
||||
Keyword::Unsubscribed => Flag::Unsubscribed,
|
||||
Keyword::Other(value) => Flag::Keyword(value),
|
||||
}
|
||||
}
|
||||
@@ -304,6 +355,23 @@ impl From<&ArchivedKeyword> for Flag {
|
||||
ArchivedKeyword::Deleted => Flag::Deleted,
|
||||
ArchivedKeyword::Forwarded => Flag::Forwarded,
|
||||
ArchivedKeyword::MdnSent => Flag::MDNSent,
|
||||
ArchivedKeyword::Autosent => Flag::Autosent,
|
||||
ArchivedKeyword::CanUnsubscribe => Flag::CanUnsubscribe,
|
||||
ArchivedKeyword::Followed => Flag::Followed,
|
||||
ArchivedKeyword::HasAttachment => Flag::HasAttachment,
|
||||
ArchivedKeyword::HasMemo => Flag::HasMemo,
|
||||
ArchivedKeyword::HasNoAttachment => Flag::HasNoAttachment,
|
||||
ArchivedKeyword::Imported => Flag::Imported,
|
||||
ArchivedKeyword::IsTrusted => Flag::IsTrusted,
|
||||
ArchivedKeyword::MailFlagBit0 => Flag::MailFlagBit0,
|
||||
ArchivedKeyword::MailFlagBit1 => Flag::MailFlagBit1,
|
||||
ArchivedKeyword::MailFlagBit2 => Flag::MailFlagBit2,
|
||||
ArchivedKeyword::MaskedEmail => Flag::MaskedEmail,
|
||||
ArchivedKeyword::Memo => Flag::Memo,
|
||||
ArchivedKeyword::Muted => Flag::Muted,
|
||||
ArchivedKeyword::New => Flag::New,
|
||||
ArchivedKeyword::Notify => Flag::Notify,
|
||||
ArchivedKeyword::Unsubscribed => Flag::Unsubscribed,
|
||||
ArchivedKeyword::Other(value) => Flag::Keyword(value.as_ref().into()),
|
||||
}
|
||||
}
|
||||
@@ -324,6 +392,23 @@ impl From<Flag> for Keyword {
|
||||
Flag::Deleted => Keyword::Deleted,
|
||||
Flag::Forwarded => Keyword::Forwarded,
|
||||
Flag::MDNSent => Keyword::MdnSent,
|
||||
Flag::Autosent => Keyword::Autosent,
|
||||
Flag::CanUnsubscribe => Keyword::CanUnsubscribe,
|
||||
Flag::Followed => Keyword::Followed,
|
||||
Flag::HasAttachment => Keyword::HasAttachment,
|
||||
Flag::HasMemo => Keyword::HasMemo,
|
||||
Flag::HasNoAttachment => Keyword::HasNoAttachment,
|
||||
Flag::Imported => Keyword::Imported,
|
||||
Flag::IsTrusted => Keyword::IsTrusted,
|
||||
Flag::MailFlagBit0 => Keyword::MailFlagBit0,
|
||||
Flag::MailFlagBit1 => Keyword::MailFlagBit1,
|
||||
Flag::MailFlagBit2 => Keyword::MailFlagBit2,
|
||||
Flag::MaskedEmail => Keyword::MaskedEmail,
|
||||
Flag::Memo => Keyword::Memo,
|
||||
Flag::Muted => Keyword::Muted,
|
||||
Flag::New => Keyword::New,
|
||||
Flag::Notify => Keyword::Notify,
|
||||
Flag::Unsubscribed => Keyword::Unsubscribed,
|
||||
Flag::Keyword(value) => Keyword::from_boxed_other(value),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user