diff --git a/src/client.rs b/src/client.rs index 411fada..6cd3985 100644 --- a/src/client.rs +++ b/src/client.rs @@ -1326,10 +1326,7 @@ impl Session { } /// Runs `COMPRESS DEFLATE` command. - /// - /// Returns `Result` which is `Ok` if the stream is now compressed - /// and `Err` if compression was not enabled. - pub async fn compress(self, f: F) -> Result, Session>> + pub async fn compress(self, f: F) -> Result> where S: Read + Write + Unpin + fmt::Debug, F: FnOnce(DeflateStream) -> S, @@ -1341,34 +1338,20 @@ impl Session { } = self; conn.run_command_and_check_ok("COMPRESS DEFLATE", Some(unsolicited_responses_tx.clone())) .await?; - let stream = conn.into_inner(); - if true { - let deflate_stream = DeflateStream::new(stream); - let stream = ImapStream::new(f(deflate_stream)); - let conn = Connection { - stream, - request_ids: IdGenerator::new(), - }; - let session = Session { - conn, - unsolicited_responses_tx, - unsolicited_responses, - }; - Ok(Ok(session)) - } else { - let stream = ImapStream::new(stream); - let conn = Connection { - stream, - request_ids: IdGenerator::new(), - }; - let session = Self { - conn, - unsolicited_responses_tx, - unsolicited_responses, - }; - Ok(Err(session)) - } + let stream = conn.into_inner(); + let deflate_stream = DeflateStream::new(stream); + let stream = ImapStream::new(f(deflate_stream)); + let conn = Connection { + stream, + request_ids: IdGenerator::new(), + }; + let session = Session { + conn, + unsolicited_responses_tx, + unsolicited_responses, + }; + Ok(session) } // these are only here because they are public interface, the rest is in `Connection`