#[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 with_suggestion(self, suggestion: impl Into<String>) -> Self
pub fn with_suggestion(self, suggestion: impl Into<String>) -> Self
Attach a near-miss suggestion.