mysql_connector/connection/
data.rs

1use {
2    super::types::AuthPlugin,
3    crate::{bitflags::CapabilityFlags, TimeoutFuture},
4    std::fmt,
5};
6
7pub struct ConnectionData {
8    pub(super) id: u32,
9    pub(super) is_mariadb: bool,
10    pub(super) version: (u16, u16, u16),
11    pub(super) capabilities: CapabilityFlags,
12    pub(super) nonce: Vec<u8>,
13    #[cfg(feature = "caching-sha2-password")]
14    #[cfg_attr(doc, doc(cfg(feature = "caching-sha2-password")))]
15    pub(super) server_key: Option<std::sync::Arc<crate::PublicKey>>,
16    pub(super) auth_plugin: AuthPlugin,
17    pub(super) auth_switched: bool,
18    pub(super) max_allowed_packet: usize,
19    pub(super) sleep: &'static (dyn Fn(std::time::Duration) -> TimeoutFuture + Send + Sync),
20}
21
22impl ConnectionData {
23    pub fn id(&self) -> u32 {
24        self.id
25    }
26
27    pub fn is_mariadb(&self) -> bool {
28        self.is_mariadb
29    }
30
31    pub fn version(&self) -> (u16, u16, u16) {
32        self.version
33    }
34
35    pub fn capabilities(&self) -> CapabilityFlags {
36        self.capabilities
37    }
38
39    pub fn auth_plugin(&self) -> AuthPlugin {
40        self.auth_plugin
41    }
42
43    pub fn max_allowed_packet(&self) -> usize {
44        self.max_allowed_packet
45    }
46}
47
48impl fmt::Debug for ConnectionData {
49    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
50        let mut debug = f.debug_struct("ConnectionData");
51        debug
52            .field("id", &self.id)
53            .field("is_mariadb", &self.is_mariadb)
54            .field("version", &self.version)
55            .field("capabilities", &self.capabilities)
56            .field("nonce", &self.nonce);
57        #[cfg(feature = "caching-sha2-password")]
58        debug.field("server_key", &self.server_key);
59        debug
60            .field("auth_plugin", &self.auth_plugin)
61            .field("auth_switched", &self.auth_switched)
62            .field("max_allowed_packet", &self.max_allowed_packet)
63            .finish()
64    }
65}