Skip to content

Commit 96e19a8

Browse files
committed
Move probe_from_env() to ProbeResult::from_env()
1 parent f2d158e commit 96e19a8

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/lib.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub unsafe fn try_init_openssl_env_vars() -> bool {
5858
///
5959
/// The probe result is returned as a [`ProbeResult`] structure here.
6060
pub fn probe() -> ProbeResult {
61-
let mut result = probe_from_env();
61+
let mut result = ProbeResult::from_env();
6262
for certs_dir in candidate_cert_dirs() {
6363
// cert.pem looks to be an openssl 1.0.1 thing, while
6464
// certs/ca-certificates.crt appears to be a 0.9.8 thing
@@ -131,23 +131,25 @@ pub fn candidate_cert_dirs() -> impl Iterator<Item = &'static Path> {
131131
///
132132
/// Returns `true` if either variable is set to an existing file or directory.
133133
pub fn has_ssl_cert_env_vars() -> bool {
134-
let probe = probe_from_env();
134+
let probe = ProbeResult::from_env();
135135
probe.cert_file.is_some() || probe.cert_dir.is_some()
136136
}
137137

138-
fn probe_from_env() -> ProbeResult {
139-
let var = |name| env::var_os(name).map(PathBuf::from).filter(|p| p.exists());
140-
ProbeResult {
141-
cert_file: var(ENV_CERT_FILE),
142-
cert_dir: var(ENV_CERT_DIR),
143-
}
144-
}
145-
146138
pub struct ProbeResult {
147139
pub cert_file: Option<PathBuf>,
148140
pub cert_dir: Option<PathBuf>,
149141
}
150142

143+
impl ProbeResult {
144+
fn from_env() -> ProbeResult {
145+
let var = |name| env::var_os(name).map(PathBuf::from).filter(|p| p.exists());
146+
ProbeResult {
147+
cert_file: var(ENV_CERT_FILE),
148+
cert_dir: var(ENV_CERT_DIR),
149+
}
150+
}
151+
}
152+
151153
/// The OpenSSL environment variable to configure what certificate file to use.
152154
pub const ENV_CERT_FILE: &'static str = "SSL_CERT_FILE";
153155

0 commit comments

Comments
 (0)