diff --git a/notes.md b/notes.md index 0629c09..854a2d9 100644 --- a/notes.md +++ b/notes.md @@ -9,3 +9,11 @@ imap routine - at this point, tls should be figured out, so moving on to auth - check if the auth type that the user specified is in the list of auth types (prob support plain and oauth2?) + +list of shit to do +--- + +- [x] starttls impl +- [ ] auth impl + - [ ] auth plain impl +- [ ] fetch impl diff --git a/src/config.rs b/src/config.rs index 88fafe7..2395966 100644 --- a/src/config.rs +++ b/src/config.rs @@ -45,14 +45,25 @@ pub struct ImapConfig { /// Port of the IMAP server pub port: u16, - /// Username for authenticating to IMAP - pub username: String, - - /// Password for authenticating to IMAP - pub password: String, - /// TLS pub tls: TlsMethod, + + /// Auth + #[serde(flatten)] + pub auth: ImapAuth, +} + +/// Method of authentication for the IMAP server +#[derive(Serialize, Deserialize, Clone, Debug)] +#[serde(tag = "auth")] +pub enum ImapAuth { + /// Use plain username/password authentication + #[serde(rename = "plain")] + #[allow(missing_docs)] + Plain { + username: String, + password: String, + } } /// Describes when to perform the TLS handshake diff --git a/src/main.rs b/src/main.rs index a3b660f..a03a18a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,17 @@ struct Opt { #[tokio::main(flavor = "multi_thread")] async fn main() -> Result<()> { + // use panorama::config::*; + // let c = ImapConfig{ + // server:String::from("ouais"), + // port: 1, + // tls: TlsMethod::Starttls, + // auth: ImapAuth::Plain{username:String::from("osu"), password:String::from("game")}, + // }; + // let s = toml::to_string(&c)?; + // println!("{}", s); + // panic!(); + // parse command line arguments into options struct let _opt = Opt::from_args();