tiberius icon indicating copy to clipboard operation
tiberius copied to clipboard

`Config::trust_cert_ca` should take Into<PathBuf> instead of ToString

Open olback opened this issue 1 year ago • 0 comments

The Config::trust_cert_ca method currently takes a path-parameter that looks like this: path: impl ToString which then gets converted to a PathBuf. Is there a reason the trust_cert_ca method doesn't take a PathBuf directly? I'd argue it would be more correct since there are valid paths that are not valid UTF-8 strings.

Current impl:

pub fn trust_cert_ca(&mut self, path: impl ToString) {
    if let TrustConfig::TrustAll = &self.trust {
        panic!("'trust_cert' and 'trust_cert_ca' are mutual exclusive! Only use one.")
    } else {
        self.trust = TrustConfig::CaCertificateLocation(PathBuf::from(path.to_string()))
    }
}

Proposed impl:

pub fn trust_cert_ca(&mut self, path: impl Into<PathBuf>) {
    if let TrustConfig::TrustAll = &self.trust {
        panic!("'trust_cert' and 'trust_cert_ca' are mutual exclusive! Only use one.")
    } else {
        self.trust = TrustConfig::CaCertificateLocation(path.into())
    }
}

I'd be happy to send a PR!

olback avatar Apr 01 '24 13:04 olback