mysql_async/opts/
native_tls_opts.rs1#![cfg(feature = "native-tls")]
2
3use std::{borrow::Cow, path::Path};
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct ClientIdentity {
7 pkcs12_path: Cow<'static, Path>,
8 password: Option<Cow<'static, str>>,
9}
10
11impl ClientIdentity {
12 pub fn new<T>(pkcs12_path: T) -> Self
14 where
15 T: Into<Cow<'static, Path>>,
16 {
17 Self {
18 pkcs12_path: pkcs12_path.into(),
19 password: None,
20 }
21 }
22
23 pub fn with_password<T>(mut self, pass: T) -> Self
25 where
26 T: Into<Cow<'static, str>>,
27 {
28 self.password = Some(pass.into());
29 self
30 }
31
32 pub fn pkcs12_path(&self) -> &Path {
34 self.pkcs12_path.as_ref()
35 }
36
37 pub fn password(&self) -> Option<&str> {
39 self.password.as_ref().map(AsRef::as_ref)
40 }
41}