#[non_exhaustive]pub struct Diagnostic {
pub code: String,
pub kind: ErrorKind,
pub message: String,
pub hint: Option<String>,
pub did_you_mean: Vec<String>,
pub location: Location,
pub data: Map<String, Value>,
pub docs_url: String,
}Expand description
One error or warning as the ADR 0026 §1 object: what the façade’s Error and Warning
serialise to, what the WASM bindings throw, as a record of strings and numbers an edge
maps one-to-one (the UniFFI Diagnostic record, the TS LaminaPdfError fields; ADR 0028
F9). Serialises with camelCase keys, optional keys omitted (never null).
Built with Diagnostic::error or Diagnostic::warning, which read the kind, hint and
docsUrl from the generated table, then the with_ methods.
message, hint and did_you_mean never carry document or caller text (ADR 0026 §4);
data is the only place such strings appear, under the keys each code’s explain page
marks untrusted.
Added in 0.2.0.
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.code: StringThe kebab-case code from fixtures/codes.json.
kind: ErrorKindOne of the nine kinds.
message: StringOne lowercase sentence (the Rust Display).
hint: Option<String>One actionable sentence for this code.
did_you_mean: Vec<String>Candidates from Lamina PDF’s own vocabulary (errors of kind usage only); empty today.
location: LocationWhere: file offset, object, stream offset, page index, LaminaPdfId.
data: Map<String, Value>Code-specific fields, documented on the code’s explain page.
docs_url: StringThe code’s explain page.
Implementations§
Source§impl Diagnostic
impl Diagnostic
Sourcepub fn error(code: ErrorCode, message: impl Into<String>) -> Self
pub fn error(code: ErrorCode, message: impl Into<String>) -> Self
The error code with message: its kind, hint and docsUrl from the generated
table; no location, data or candidates. message is one lowercase sentence that
never quotes the document or the caller (ADR 0026 §4).
Added in 0.2.0.
Sourcepub fn warning(code: WarningCode) -> Self
pub fn warning(code: WarningCode) -> Self
The warning code: its kind, hint and docsUrl from the generated table, and its
fixed summary as the message.
Added in 0.2.0.
Sourcepub fn with_hint(self, hint: Option<String>) -> Self
pub fn with_hint(self, hint: Option<String>) -> Self
With hint in place of the code’s (a hint with its parameter filled in).
Added in 0.2.0.
Sourcepub fn with_did_you_mean(self, did_you_mean: Vec<String>) -> Self
pub fn with_did_you_mean(self, did_you_mean: Vec<String>) -> Self
With the candidates for didYouMean (errors of kind usage only).
Added in 0.2.0.
Sourcepub fn with_location(self, location: Location) -> Self
pub fn with_location(self, location: Location) -> Self
With where the problem was found.
Added in 0.2.0.