Reduce visibility of some methods in CertGenMode, fix docs

This commit is contained in:
Emi Tatsuo 2020-12-03 05:20:16 -05:00
parent e55f5c675b
commit d71c3f952d
Signed by: Emi
GPG Key ID: 68FAB2E2E6DFC98B
1 changed files with 10 additions and 2 deletions

View File

@ -28,7 +28,10 @@ use rustls::*;
#[cfg(feature = "certgen")]
/// The mode to use for determining the domains to use for a new certificate.
///
/// Used to configure a [`Server`] using [`Server::set_certificate_generation_mode()`]
/// Used to configure a [`Server`] using [`set_certificate_generation_mode()`]
///
/// [`Server`]: crate::Server
/// [`set_certificate_generation_mode()`]: crate::Server::set_certificate_generation_mode
pub enum CertGenMode {
/// Do not generate any certificates. Error if not available.
@ -49,10 +52,15 @@ impl CertGenMode {
/// provided paths. The paths provided should be paths to non-existant files which
/// the program has access to write to.
///
/// With very rare exceptions, end users should not ever need to call this method.
/// Instead, just pass the [`CertGenMode`] to [`set_certificate_generation_mode()`]
///
/// ## Errors
///
/// Returns an error if [`CertGenMode::None`], or if there is an error generating the
/// certificate, or writing to either of the provided files.
///
/// [`set_certificate_generation_mode()`]: crate::Server::set_certificate_generation_mode
pub fn gencert(self, cert: impl AsRef<Path>, key: impl AsRef<Path>) -> Result<rcgen::Certificate> {
let (domains, interactive) = match self {
Self::None => bail!("Automatic certificate generation disabled"),
@ -96,7 +104,7 @@ impl CertGenMode {
/// ## Errors
///
/// Returns an error if a certificate is not found **and** cannot be generated.
pub fn load_or_generate(self, to: &mut ServerConfig, cert: impl AsRef<Path>, key: impl AsRef<Path>) -> Result<()> {
fn load_or_generate(self, to: &mut ServerConfig, cert: impl AsRef<Path>, key: impl AsRef<Path>) -> Result<()> {
match (load_cert_chain(&cert.as_ref().into()), load_key(&key.as_ref().into())) {
(Ok(cert_chain), Ok(key)) => {
to.set_single_cert(cert_chain, key)