1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
use std::fmt;

use super::NntpCommand;

/// Authenticate via `AUTHINFO` as specified in [RFC 4643](https://tools.ietf.org/html/rfc4643)
///
/// # Limitations
///
/// * SASL is not currently implemented
#[derive(Clone, Debug)]
pub enum AuthInfo {
    /// Username
    User(String),
    /// Password
    Pass(String),
}

impl fmt::Display for AuthInfo {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        match self {
            AuthInfo::User(username) => write!(f, "AUTHINFO USER {}", username),
            AuthInfo::Pass(password) => write!(f, "AUTHINFO PASS {}", password),
        }
    }
}

impl NntpCommand for AuthInfo {}