#[non_exhaustive]pub enum RefParseError {
Empty,
MissingDoiPrefix,
MissingDoiSuffixSeparator,
InvalidDoiRegistrant,
EmptyDoiSuffix,
DoiSuffixTooLong {
len: usize,
max: usize,
},
InvalidDoiSuffixChar {
ch: char,
},
InvalidArxivShape,
UnrecognisedShape,
}Expand description
Reasons a Doi::parse / ArxivId::parse / Ref::parse call can fail.
Each variant maps to one rejection category in docs/SECURITY.md §1.1.
All variants funnel to ErrorCode::InvalidRef when surfacing to MCP /
CLI; the granular shape is preserved for tests and for future log
breadcrumbs. The From<RefParseError> for ErrorCode impl below makes
? propagation collapse to INVALID_REF automatically, satisfying
docs/PUBLIC_API.md §4.
Marked #[non_exhaustive] so adding new categories is a non-breaking
change. Pattern-match with a wildcard arm.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Empty
Input was empty.
MissingDoiPrefix
Input did not begin with the required 10. literal (after any
scheme strip).
MissingDoiSuffixSeparator
Input started with 10. but had no / separator between
registrant and suffix.
InvalidDoiRegistrant
Registrant was not 4–9 ASCII digits.
EmptyDoiSuffix
DOI suffix was empty.
DoiSuffixTooLong
DOI suffix exceeded DOI_SUFFIX_MAX_LEN bytes.
Fields
max: usizeHard upper bound (always DOI_SUFFIX_MAX_LEN).
InvalidDoiSuffixChar
DOI suffix contained a character outside [A-Za-z0-9._/():-].
InvalidArxivShape
Input matched neither the new-style nor old-style arXiv shape.
UnrecognisedShape
Input carried no scheme and no 10. prefix, so it could have been
either kind of ref, and it was neither.
#477: the fall-through used to report Self::InvalidArxivShape,
so someone who mistyped a DOI was told about arXiv. The input names
no shape, so neither should the error.
Trait Implementations§
Source§impl Clone for RefParseError
impl Clone for RefParseError
Source§impl Debug for RefParseError
impl Debug for RefParseError
Source§impl Display for RefParseError
impl Display for RefParseError
impl Eq for RefParseError
Source§impl Error for RefParseError
impl Error for RefParseError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()