Skip to main content

Diagnostic

Struct Diagnostic 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§code: String

The kebab-case code from fixtures/codes.json.

§kind: ErrorKind

One of the nine kinds.

§message: String

One 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: Location

Where: file offset, object, stream offset, page index, LaminaPdfId.

§data: Map<String, Value>

Code-specific fields, documented on the code’s explain page.

§docs_url: String

The code’s explain page.

Implementations§

Source§

impl Diagnostic

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_location(self, location: Location) -> Self

With where the problem was found.

Added in 0.2.0.

Source

pub fn with_data(self, data: Map<String, Value>) -> Self

With the code-specific fields its explain page lists.

Added in 0.2.0.

Source

pub fn to_json(&self) -> Value

The record as a JSON value (the §1 object).

Added in 0.2.0.

Trait Implementations§

Source§

impl Clone for Diagnostic

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Diagnostic

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Diagnostic

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Diagnostic

Auto Trait Implementations§

§

impl Forget for Diagnostic

§

impl Freeze for Diagnostic
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, PhantomData<String>: Freeze, *const LeafNode<String, Value> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(String, Value)>>: Freeze,

§

impl Move for Diagnostic

§

impl RefUnwindSafe for Diagnostic

§

impl Send for Diagnostic
where RawVecInner: Send, NodeRef<Owned, String, Value, LeafOrInternal>: Send, BoxRaw<(String, Value)>: Send,

§

impl Sync for Diagnostic
where RawVecInner: Sync, NodeRef<Owned, String, Value, LeafOrInternal>: Sync, BoxRaw<(String, Value)>: Sync,

§

impl Unpin for Diagnostic
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for Diagnostic

§

impl UnwindSafe for Diagnostic
where RawVecInner: UnwindSafe, BTreeMap<String, Value>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.