sasl/client/mechanisms/
anonymous.rsuse crate::client::{Mechanism, MechanismError};
use crate::common::{Credentials, Secret};
pub struct Anonymous;
impl Anonymous {
#[allow(clippy::new_without_default)]
pub fn new() -> Anonymous {
Anonymous
}
}
impl Mechanism for Anonymous {
fn name(&self) -> &str {
"ANONYMOUS"
}
fn from_credentials(credentials: Credentials) -> Result<Anonymous, MechanismError> {
if let Secret::None = credentials.secret {
Ok(Anonymous)
} else {
Err(MechanismError::AnonymousRequiresNoCredentials)
}
}
}