From a481c6f0c7364259d49450406a80b9b78cdaad70 Mon Sep 17 00:00:00 2001 From: Miquel Ruiz Date: Sun, 10 Jul 2016 20:55:30 +0100 Subject: [PATCH] Support for UID STORE --- src/client.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/client.rs b/src/client.rs index 53c590e..c3460db 100644 --- a/src/client.rs +++ b/src/client.rs @@ -215,6 +215,10 @@ impl Client { self.run_command_and_read_response(&format!("STORE {} {}", sequence_set, query)) } + pub fn uid_store(&mut self, uid_set: &str, query: &str) -> Result> { + self.run_command_and_read_response(&format!("UID STORE {} {}", uid_set, query)) + } + /// Copy copies the specified message to the end of the specified destination mailbox. pub fn copy(&mut self, sequence_set: &str, mailbox_name: &str) -> Result<()> { self.run_command_and_check_ok(&format!("COPY {} {}", sequence_set, mailbox_name).to_string()) @@ -568,16 +572,30 @@ mod tests { #[test] fn store() { + generic_store(false); + } + + #[test] + fn uid_store() { + generic_store(true); + } + + fn generic_store(uid: bool) { let response = b"* 2 FETCH (FLAGS (\\Deleted \\Seen))\r\n\ * 3 FETCH (FLAGS (\\Deleted))\r\n\ * 4 FETCH (FLAGS (\\Deleted \\Flagged \\Seen))\r\n\ a1 OK STORE completed\r\n".to_vec(); let sequence_set = "2:4"; let query = "+FLAGS (\\Deleted)"; - let command = format!("a1 STORE {} {}\r\n", sequence_set, query); + let uid_cmd = if uid { " UID " } else { " " }; + let command = format!("a1{}STORE {} {}\r\n", uid_cmd, sequence_set, query); let mock_stream = MockStream::new(response); let mut client = Client::new(mock_stream); - client.store(sequence_set, query).unwrap(); + if uid { + client.uid_store(sequence_set, query).unwrap(); + } else { + client.store(sequence_set, query).unwrap(); + } assert!(client.stream.written_buf == command.as_bytes().to_vec(), "Invalid store command"); } }