#[non_exhaustive]pub struct Issue {
pub kind: IssueKind,
pub value: String,
pub suggestion: Option<String>,
}Expand description
Why a value failed to validate.
Structured rather than pre-rendered, for the same reason crate::Presentation
carries semantic hints rather than colours: the embedder owns presentation.
A frontend can localize the text, or offer Issue::suggestion as a
one-tap correction instead of prose. Display renders
the English default.
#[non_exhaustive]: an issue can gain context (a span, a source) without
costing downstream a major. Build one with Issue::unknown,
Issue::retired or Issue::custom; reading the fields is unchanged.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.kind: IssueKindWhat went wrong.
value: StringThe offending value, as text.
suggestion: Option<String>A near miss from the vocabulary, when one is close enough to be worth offering.
Implementations§
Source§impl Issue
impl Issue
Sourcepub fn retired(value: impl Into<String>) -> Self
pub fn retired(value: impl Into<String>) -> Self
A value that is in the vocabulary but retired.
Sourcepub fn custom(value: impl Into<String>, message: impl Into<String>) -> Self
pub fn custom(value: impl Into<String>, message: impl Into<String>) -> Self
An embedder-defined issue with its own message.
Sourcepub fn unchecked(value: impl Into<String>, kind: impl Into<String>) -> Self
pub fn unchecked(value: impl Into<String>, kind: impl Into<String>) -> Self
A value that could not be checked, because its constraint is of a
kind this validator does not know. Wrap it in Validation::Reject
— the fail-closed half of the rule is the caller’s — and see
IssueKind::Unchecked for the other half.
Sourcepub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Attach a near-miss suggestion.
Sourcepub fn is_unchecked(&self) -> bool
pub fn is_unchecked(&self) -> bool
Whether this says the value was not checked rather than that it is
wrong — see IssueKind::Unchecked. A rejection carrying one is still
a rejection; this is how a reader that wants to report the two
differently tells them apart.