Lyricdev
GitHub

interface Decode

pub interface Decode

A value that reads itself out of any decoder.

Methods

static fn decode<D :: [Decoder]>(&d: D): Self throws DecodeError

Reads a value of this type out of d. Synthesized for a conformance without the member, as the mirror of encode: a struct's fields by their wire names, a field the data lacks as decodeAbsent gives it (null for an optional, Missing else), unknown fields passed unless @Codec { denyUnknown }; an enum's variant by its name, or by the tag.

Errors

Throws DecodeError: Missing for an absent required field, UnknownVariant for a variant name or index the enum has not, UnknownField under denyUnknown, and whatever the decoder throws for a mismatched or invalid value.

static fn decodeAbsent<D :: [Decoder]>(&d: D, name: string): Self throws DecodeError

Returns what a field the data lacks reads as: null for an optional (whose conformance overrides this member).

Errors

Throws DecodeError of kind Missing for any type that does not override it.