diff --git a/src/client.rs b/src/client.rs index f93728c..c80fb12 100644 --- a/src/client.rs +++ b/src/client.rs @@ -3,7 +3,7 @@ use openssl::ssl::{SslContext, SslStream}; use std::io::{self, Read, Write}; use super::mailbox::Mailbox; -use super::parse::{parse_response_ok, parse_capability, parse_select_or_examine}; +use super::parse::{parse_response_ok, parse_capability, parse_select_or_examine, parse_response}; use super::error::{Error, Result}; static TAG_PREFIX: &'static str = "a"; @@ -146,6 +146,15 @@ impl Client { self.run_command_and_check_ok(&format!("COPY {} {}", sequence_set, mailbox_name).to_string()) } + /// The LIST command returns a subset of names from the complete set + /// of all names available to the client. + pub fn list(&mut self, reference_name: &str, mailbox_search_pattern: &str) -> Result> { + match self.run_command(&format!("LIST {} {}", reference_name, mailbox_search_pattern)) { + Ok(lines) => parse_response(lines), + Err(e) => Err(e) + } + } + /// Runs a command and checks if it returns OK. pub fn run_command_and_check_ok(&mut self, command: &str) -> Result<()> { match self.run_command(command) {