panorama/imap/src/command/mod.rs

25 lines
759 B
Rust
Raw Normal View History

2021-02-20 05:03:33 +00:00
use std::fmt;
/// Commands, without the tag part.
2021-02-20 07:30:58 +00:00
#[derive(Clone, Debug)]
2021-02-20 05:03:33 +00:00
pub enum Command {
Capability,
2021-02-21 13:42:40 +00:00
Starttls,
2021-02-23 02:47:00 +00:00
Login { username: String, password: String },
2021-02-23 04:01:39 +00:00
Select { mailbox: String },
List { reference: String, mailbox: String },
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-20 05:03:33 +00:00
}
}
}