From 0c3ce7943dbaae422211ea12bd8c4a7d8e7d6fa9 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Mon, 18 May 2020 14:12:10 -0400 Subject: [PATCH 1/3] Expose unilateral mailbox flag changes This is a backwards incompatible change, since it adds a variant to a public enum. --- src/parse.rs | 11 +++++++++-- src/types/mod.rs | 9 +++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/parse.rs b/src/parse.rs index b2dc002..b7418a9 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -322,8 +322,15 @@ fn handle_unilateral<'a>( Response::MailboxData(MailboxDatum::Recent(n)) => { unsolicited.send(UnsolicitedResponse::Recent(n)).unwrap(); } - Response::MailboxData(MailboxDatum::Flags(_)) => { - // TODO: next breaking change: + Response::MailboxData(MailboxDatum::Flags(flags)) => { + unsolicited + .send(UnsolicitedResponse::Flags( + flags + .into_iter() + .map(|s| Flag::from(s.to_string())) + .collect(), + )) + .unwrap(); } Response::MailboxData(MailboxDatum::Exists(n)) => { unsolicited.send(UnsolicitedResponse::Exists(n)).unwrap(); diff --git a/src/types/mod.rs b/src/types/mod.rs index 4a789e5..9757680 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -262,6 +262,15 @@ pub enum UnsolicitedResponse { /// sequence numbers 9, 8, 7, 6, and 5. // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? Expunge(Seq), + + /// An unsolicited [`FLAGS` response](https://tools.ietf.org/html/rfc3501#section-7.2.6) that + /// identifies the flags (at a minimum, the system-defined flags) that are applicable in the + /// mailbox. Flags other than the system flags can also exist, depending on server + /// implementation. + /// + /// See [`Flag`] for details. + // TODO: the spec doesn't seem to say anything about when these may be received as unsolicited? + Flags(Vec>), } /// This type wraps an input stream and a type that was constructed by parsing that input stream, From cf4aed569b62dfcc9dea0b54778bba4886de06d3 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Mon, 18 May 2020 14:12:34 -0400 Subject: [PATCH 2/3] Make UnsolicitedResponse non_exhaustive That way, as we discover additional unilateral responses in the future, we won't have to make a breaking change to add them. --- src/types/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/types/mod.rs b/src/types/mod.rs index 9757680..8a13903 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -211,6 +211,7 @@ pub use imap_proto::StatusAttribute; /// Note that `Recent`, `Exists` and `Expunge` responses refer to the currently `SELECT`ed folder, /// so the user must take care when interpreting these. #[derive(Debug, PartialEq, Eq)] +#[non_exhaustive] pub enum UnsolicitedResponse { /// An unsolicited [`STATUS response`](https://tools.ietf.org/html/rfc3501#section-7.2.4). Status { From 02ce8cb5118e77e0ff6287418074a954ba9acfc6 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Mon, 18 May 2020 14:28:08 -0400 Subject: [PATCH 3/3] Bump MSRV for non_exhaustive --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5cc11d8..f9e126c 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -47,12 +47,12 @@ jobs: - job: msrv pool: vmImage: ubuntu-latest - displayName: "Minimum supported Rust version: 1.36.0" + displayName: "Minimum supported Rust version: 1.40.0" dependsOn: [] steps: - template: install-rust.yml@templates parameters: - rust: 1.36.0 + rust: 1.40.0 - script: cargo check displayName: cargo check - job: integration