From c9b720155fac28a0e9448a7ba21a335d2590c09f Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Thu, 4 Oct 2018 11:57:45 +0200 Subject: [PATCH 1/2] client: Add UID EXPUNGE support --- src/client.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/client.rs b/src/client.rs index 43f0c5d..59f54d6 100644 --- a/src/client.rs +++ b/src/client.rs @@ -532,6 +532,12 @@ impl Session { self.run_command_and_check_ok("EXPUNGE") } + /// Permanently removes all messages that have both the \Deleted flag set and have a UID that is + /// included in the specified message set. + pub fn uid_expunge(&mut self, uid_set: &str) -> Result<()> { + self.run_command_and_check_ok(&format!("UID EXPUNGE {}", uid_set)) + } + /// Check requests a checkpoint of the currently selected mailbox. pub fn check(&mut self) -> Result<()> { self.run_command_and_check_ok("CHECK") @@ -960,6 +966,21 @@ mod tests { ); } + #[test] + fn uid_expunge() { + let response = b"* 2 EXPUNGE\r\n\ + * 3 EXPUNGE\r\n\ + * 4 EXPUNGE\r\n\ + a1 OK UID EXPUNGE completed\r\n".to_vec(); + let mock_stream = MockStream::new(response); + let mut session = mock_session!(mock_stream); + session.uid_expunge("2:4").unwrap(); + assert!( + session.stream.get_ref().written_buf == b"a1 UID EXPUNGE 2:4\r\n".to_vec(), + "Invalid expunge command" + ); + } + #[test] fn check() { let response = b"a1 OK CHECK completed\r\n".to_vec(); From 4321b7fe145e88e93f5e23e4fc6be1e8bd3a4a71 Mon Sep 17 00:00:00 2001 From: Massimiliano Torromeo Date: Fri, 5 Oct 2018 17:21:22 +0200 Subject: [PATCH 2/2] Add reference to the RFC defining the UID EXPUNGE command --- src/client.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client.rs b/src/client.rs index 59f54d6..f9e6002 100644 --- a/src/client.rs +++ b/src/client.rs @@ -534,6 +534,7 @@ impl Session { /// Permanently removes all messages that have both the \Deleted flag set and have a UID that is /// included in the specified message set. + /// The UID EXPUNGE command is defined in [RFC 4315 - "Internet Message Access Protocol (IMAP) - UIDPLUS extension"](https://tools.ietf.org/html/rfc4315#section-2.1). pub fn uid_expunge(&mut self, uid_set: &str) -> Result<()> { self.run_command_and_check_ok(&format!("UID EXPUNGE {}", uid_set)) }