Plushie.Event.Diagnostic (Plushie v0.7.1)

Copy Markdown View Source

Typed diagnostic variants emitted by the renderer.

The renderer's plushie-core::Diagnostic enum enumerates every diagnostic the renderer can emit (tree normalization warnings, prop validation, font cap, panic guards, transport violations). Each variant arrives on the wire as a map with a discriminator ("kind": "...") and variant-specific fields. decode!/1 dispatches on that discriminator to one of the structs defined here so app authors pattern match on a typed struct rather than a raw map.

Decoded diagnostics are delivered through Plushie.Event.DiagnosticMessage, which carries the session ID, severity level, and the typed diagnostic. Apps typically match both:

def update(model, %DiagnosticMessage{diagnostic: %FontFamilyNotFound{family: f}}) do
  Logger.warning("font missing: #{f}")
  model
end

Unknown variants

The decoder raises ArgumentError on an unrecognised kind. A new renderer variant requires an SDK update; silently dropping unknown diagnostics would hide host/renderer version skew that the runtime needs to see.

Summary

Types

t()

Any typed diagnostic variant struct.

Functions

Decode a typed diagnostic from a wire payload map.

List of wire-level kind strings this SDK version decodes.

Types

t()

Any typed diagnostic variant struct.

Functions

decode!(payload)

@spec decode!(map()) :: t()

Decode a typed diagnostic from a wire payload map.

The payload is the value of the diagnostic field on the top-level diagnostic wire message: a map containing "kind" plus variant- specific fields.

Raises ArgumentError on an unknown kind.

known_kinds()

@spec known_kinds() :: [String.t()]

List of wire-level kind strings this SDK version decodes.

Useful for test assertions that the SDK's typed-variant coverage matches the renderer's enum.