Skip to content

Commit

Permalink
rename enum option
Browse files Browse the repository at this point in the history
  • Loading branch information
melekes committed Nov 17, 2022
1 parent 3be3a5d commit 3f417fe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion client/cli/src/params/webrtc_certificate_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl WebRTCCertificateParams {
.clone()
.unwrap_or_else(|| net_config_dir.join(WEBRTC_CERTIFICATE_FILENAME));

Ok(WebRTCConfig::Certificate(Some(cert)))
Ok(WebRTCConfig::File(Some(cert)))
}
}

Expand Down
12 changes: 6 additions & 6 deletions client/network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,12 +465,12 @@ where
#[derive(Clone, Debug)]
pub enum WebRTCConfig {
/// A WebRTC certificate.
Certificate(Option<PathBuf>),
File(Option<PathBuf>),
}

impl Default for WebRTCConfig {
fn default() -> WebRTCConfig {
Self::Certificate(None)
Self::File(None)
}
}

Expand All @@ -490,7 +490,7 @@ impl WebRTCConfig {

use WebRTCConfig::*;
match self {
Certificate(Some(filepath)) => {
File(Some(filepath)) => {
let f = std::fs::read(&filepath).or_else(|e| {
if e.kind() == io::ErrorKind::NotFound {
<PathBuf as AsRef<Path>>::as_ref(&filepath)
Expand All @@ -517,7 +517,7 @@ impl WebRTCConfig {
WebRTCCertificate::from_pem(&pem)
.map_err(|e| io::Error::new(io::ErrorKind::Other, e.to_string()))
},
Certificate(None) => generate(),
File(None) => generate(),
}
}
}
Expand Down Expand Up @@ -566,8 +566,8 @@ mod tests {
let tmp = tempdir_with_prefix("x");
std::fs::remove_dir(tmp.path()).unwrap(); // should be recreated
let file = tmp.path().join("x").to_path_buf();
let kp1 = WebRTCConfig::Certificate(Some(file.clone())).into_certificate().unwrap();
let kp2 = WebRTCConfig::Certificate(Some(file.clone())).into_certificate().unwrap();
let kp1 = WebRTCConfig::File(Some(file.clone())).into_certificate().unwrap();
let kp2 = WebRTCConfig::File(Some(file.clone())).into_certificate().unwrap();
assert!(file.is_file() && kp1 == kp2)
}
}

0 comments on commit 3f417fe

Please sign in to comment.