panorama/imap/src/command/mod.rs

39 lines
940 B
Rust
Raw Normal View History

2021-02-20 05:03:33 +00:00
use std::fmt;
/// Commands, without the tag part.
#[derive(Clone)]
2021-02-20 05:03:33 +00:00
pub enum Command {
Capability,
2021-02-21 13:42:40 +00:00
Starttls,
2021-02-24 12:43:50 +00:00
Login {
username: String,
password: String,
},
Select {
mailbox: String,
},
List {
reference: String,
mailbox: String,
},
#[cfg(feature = "rfc2177-idle")]
Idle,
2021-02-20 05:03:33 +00:00
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2021-02-23 04:01:39 +00:00
use Command::*;
2021-02-20 05:03:33 +00:00
match self {
2021-02-23 04:01:39 +00:00
Capability => write!(f, "CAPABILITY"),
Starttls => write!(f, "STARTTLS"),
Login { username, password } => write!(f, "LOGIN {} {}", username, password),
Select { mailbox } => write!(f, "SELECT {}", mailbox),
List { reference, mailbox } => write!(f, "LIST {:?} {:?}", reference, mailbox),
2021-02-24 12:43:50 +00:00
#[cfg(feature = "rfc2177-idle")]
Idle => write!(f, "IDLE"),
2021-02-20 05:03:33 +00:00
}
}
}