1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
//! Public errors
/// Parsing Detail relating to an Error
#[derive(Clone, Debug, PartialEq)]
pub struct ParsingDetail<'hdr> {
/// Component
pub component: &'static str,
/// Span start
pub span_start: usize,
/// Span end
pub span_end: usize,
/// Source
pub source: &'hdr str,
/// Clipped span
pub clipped_span: &'hdr str,
/// Clipped remaining
pub clipped_remaining: &'hdr str,
}
/// Errors relating to parsing Authentication-Results Header
#[derive(Clone, Debug, PartialEq)]
pub enum AuthResultsError<'hdr> {
/// Could not find the ending for unknown method block beginning from
RunawayUnknownMethod(usize),
/// Detailed with ParsingDetail
ParsingDetailed(ParsingDetail<'hdr>),
/// No header
NoHeader,
/// Unknown parsing error
Parse,
/// Host parsing error
ParseHost(String),
/// Bug
ParsePtypeBugGating,
/// Bug
ParsePtypeBugInvalidProperty,
/// Bug
ParsePtypeBugPropertyGating,
/// Invalid associated ptype Encountered
ParsePtypeInvalidAssociatedPtype(ParsingDetail<'hdr>),
/// Invalid dkim method Result Code
InvalidDkimResult(String),
/// Invalid spf method Result Code
InvalidSpfResult(String),
/// Invalid iprev method Result Code
InvalidIpRevResult(String),
/// Was not a valid ptype/property per IANA and strict validation was used
InvalidProperty,
/// Invalid auth method Result code
InvalidSmtpAuthResult(String),
/// Invalid stage in result
InvalidResultStage,
/// Invalid version - Only 1 allowed
InvalidVersion,
/// No associated version found when required
NoAssociatedVersion,
/// No associated policy found when defined
NoAssociatedPolicy,
/// No assicited reason found when defined
NoAssociatedReason,
/// No hostname found that is required
NoHostname,
/// Err
ParsePtypeNoMethodResult,
/// Bug property keys not implemented for ptype
PropertiesNotImplemented,
/// Bug property values not implemented for ptype
PropertyValuesNotImplemented,
/// Run-away auth method property key
RunAwayAuthPropertyKey,
/// Run-away auth method property value
RunAwayAuthPropertyValue,
/// Run-away comment
RunAwayComment,
/// Run-away dkim method property key
RunAwayDkimPropertyKey,
/// Run-away dkim method property value
RunAwayDkimPropertyValue,
/// Run-away iprev method property key
RunAwayIpRevPropertyKey,
/// Run-away iprev method property value
RunAwayIpRevPropertyValue,
/// Run-away spf method property key
RunAwaySpfPropertyKey,
/// Run-away spf method property value
RunAwaySpfPropertyValue,
/// Unexpected forward slash
UnexpectedForwardSlash,
/// Bug
ParseCurrentPushNotImplemented,
}
/// DKIM-Signature header parsing Errors
#[derive(Debug)]
pub enum DkimSignatureError<'hdr> {
/// Detailed with ParsingDetail
ParsingDetailed(ParsingDetail<'hdr>),
/// No tags found at all
NoTagFound,
/// Encountered unexpected Equal '=' character when a tag was expected
UnexpectedEqual,
/// Error (from lexer) trying to parse value - Unmatched
ParseValueUnmatch,
/// Error (from parse conversion) trying to parse a valid value on tag
ParseValueInvalid(DkimTagValueError),
/// Missign Required v=
MissingVersion,
/// Msising Required a=
MissingAlgorithm,
/// Msising Required b=
MissingSignature,
/// Missing Required bh=
MissingBodyHash,
/// Missing Required d=
MissingResponsibleSdid,
/// Msising Required h=
MissingSignedHeaderFields,
/// Missing Required s=
MissingSelector,
}
/// Currently no error - may change in future
#[derive(Debug, PartialEq)]
pub enum DkimAlgorithmError {}
/// Currently infallible may be changed in the future
#[derive(Clone, Debug, PartialEq)]
pub enum DkimCanonicalizationError {}
/// Currently infallible, may change in the future
#[derive(Debug, PartialEq)]
pub enum DkimTimestampError {}
/// Currently infallible, may change in the future
#[derive(Debug, PartialEq)]
pub enum DkimVersionError {}
// Currently no errors - may change in the future
//#[derive(Clone, Debug, PartialEq)]
//pub enum DkimHeaderError {}
/// DKIM Header tags values parsing error
#[derive(Debug, PartialEq)]
pub enum DkimTagValueError {
/// Tag value must appear only once per tag
Duplicate,
/// DKIM Timestamp parsing error
Timestamp(DkimTimestampError),
/// DKIM Canonizalition parsing error
Canonicalization(DkimCanonicalizationError),
/// DKIM Algorithm parsing error
Algorithm(DkimAlgorithmError),
/// DKIM Version parsing error
Version(DkimVersionError),
}
impl<'hdr> From<DkimTagValueError> for DkimSignatureError<'hdr> {
fn from(e: DkimTagValueError) -> Self {
Self::ParseValueInvalid(e)
}
}
impl From<DkimTimestampError> for DkimTagValueError {
fn from(e: DkimTimestampError) -> Self {
Self::Timestamp(e)
}
}
impl From<DkimCanonicalizationError> for DkimTagValueError {
fn from(e: DkimCanonicalizationError) -> Self {
Self::Canonicalization(e)
}
}
impl From<DkimAlgorithmError> for DkimTagValueError {
fn from(e: DkimAlgorithmError) -> Self {
Self::Algorithm(e)
}
}
impl From<DkimVersionError> for DkimTagValueError {
fn from(e: DkimVersionError) -> Self {
Self::Version(e)
}
}