mysql_binlog_connector_rust/command/
auth_plugin.rs

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
use core::str;

#[derive(PartialEq, Clone)]
pub enum AuthPlugin {
    Unsupported,
    MySqlNativePassword,
    CachingSha2Password,
}

impl AuthPlugin {
    pub fn to_str(&self) -> &str {
        match self {
            AuthPlugin::MySqlNativePassword => "mysql_native_password",
            AuthPlugin::CachingSha2Password => "caching_sha2_password",
            _ => "unsupported",
        }
    }

    pub fn from_name(name: &str) -> Self {
        match name.to_lowercase().as_str() {
            "mysql_native_password" => AuthPlugin::MySqlNativePassword,
            "caching_sha2_password" => AuthPlugin::CachingSha2Password,
            _ => AuthPlugin::Unsupported,
        }
    }
}