Refactoring loading of config file
- let `HuskConfig::load` return a `Result` instead of an `Option`. - added comments
This commit is contained in:
@@ -8,6 +8,10 @@ use thiserror::Error;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
pub enum HuskError {
|
||||
#[error("Cannot open config file: {0}")]
|
||||
ConfigFileOpenError(String),
|
||||
#[error("Error while parsing config file: {0}")]
|
||||
ConfigFileParseError(String),
|
||||
#[error("Cannot find local trust root")]
|
||||
NoLocalTrustRoot,
|
||||
#[error("Cannot access cert store")]
|
||||
|
||||
@@ -19,7 +19,7 @@ impl Introducer {
|
||||
pub fn can_introduce(&self, email: &str) -> bool {
|
||||
if let Some(regexset) = self.certification.regular_expressions() {
|
||||
if regexset.matches_everything() {
|
||||
// return false, because unlimited certifications are
|
||||
// return false, because unlimited certifications are
|
||||
// ignored.
|
||||
false
|
||||
} else {
|
||||
|
||||
@@ -12,8 +12,11 @@ use crate::types::recipient::Recipient;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum ProtectionPossibility {
|
||||
// no recipient has a cert
|
||||
NoProtection,
|
||||
// some recipients have a cert (but not all)
|
||||
Partial,
|
||||
// all recipients have a cert
|
||||
Full
|
||||
}
|
||||
|
||||
@@ -82,7 +85,8 @@ impl From<&MailContext<'_>> for ProtectionPossibility {
|
||||
(true, false) => ProtectionPossibility::Full,
|
||||
(true, true) => ProtectionPossibility::Partial,
|
||||
(false, true) => ProtectionPossibility::NoProtection,
|
||||
(false, false) => ProtectionPossibility::NoProtection, // this should not occure
|
||||
// (false, false) occurs if there are no recipients
|
||||
(false, false) => ProtectionPossibility::NoProtection,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,10 +37,14 @@ impl TryFrom<CString> for Recipient<'_> {
|
||||
}
|
||||
|
||||
impl Recipient<'_> {
|
||||
/// check if this Recipient can encrypt.
|
||||
// XXX: currently this check is naive
|
||||
pub fn can_encrypt(&self) -> bool {
|
||||
if self.certs.len() == 0 {
|
||||
return false;
|
||||
}
|
||||
|
||||
// XXX: add check to see if a cert has encryption capable subkeys
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user