sasl/client/mechanisms/
anonymous.rs1use crate::client::{Mechanism, MechanismError};
4use crate::common::{Credentials, Secret};
5
6pub struct Anonymous;
8
9impl Anonymous {
10 #[allow(clippy::new_without_default)]
15 pub fn new() -> Anonymous {
16 Anonymous
17 }
18}
19
20impl Mechanism for Anonymous {
21 fn name(&self) -> &str {
22 "ANONYMOUS"
23 }
24
25 fn from_credentials(credentials: Credentials) -> Result<Anonymous, MechanismError> {
26 if let Secret::None = credentials.secret {
27 Ok(Anonymous)
28 } else {
29 Err(MechanismError::AnonymousRequiresNoCredentials)
30 }
31 }
32}