From 0c3ce7943dbaae422211ea12bd8c4a7d8e7d6fa9 Mon Sep 17 00:00:00 2001 From: Jon Gjengset Date: Mon, 18 May 2020 14:12:10 -0400 Subject: [PATCH] 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,