pub struct Doi(/* private fields */);Expand description
A validated DOI string.
Construct via Doi::parse(s) (Phase 1+). The inner field is intentionally
pub(crate) to forbid bypass construction; tests inside doiget-core may
still use Doi(s) for fixture purposes.
Wire format: bare string (#[serde(transparent)]), e.g. "10.1234/example".
Implementations§
Source§impl Doi
impl Doi
Sourcepub fn parse(s: &str) -> Result<Self, RefParseError>
pub fn parse(s: &str) -> Result<Self, RefParseError>
Parses and validates a DOI string per docs/SECURITY.md §1.1.
Accepts:
- Bare DOIs:
10.<registrant>/<suffix>where<registrant>is 4–9 digits and<suffix>is a non-empty sequence of characters drawn from[A-Za-z0-9._/()-]. - The
doi:URI scheme prefix; it is stripped before validation, so the stored value never carries a scheme. (Matches the convention established indocs/SAFEKEY.md§3 step 0.)
Rejects:
- Inputs missing the literal
10.prefix (after optional scheme strip). - Suffixes longer than
DOI_SUFFIX_MAX_LENbytes. - Empty suffixes.
- Any character outside the suffix charset above (including control characters, whitespace, and non-ASCII).
§Errors
Returns a RefParseError variant that names the specific rejection
category. Tier 1+ callers should map any RefParseError to
ErrorCode::InvalidRef when surfacing to MCP / CLI.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Doi
impl<'de> Deserialize<'de> for Doi
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Doi
impl StructuralPartialEq for Doi
Auto Trait Implementations§
impl Freeze for Doi
impl RefUnwindSafe for Doi
impl Send for Doi
impl Sync for Doi
impl Unpin for Doi
impl UnsafeUnpin for Doi
impl UnwindSafe for Doi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more