Lyricdev
GitHub

struct Codec

pub struct Codec :: [OnField, OnType]

Conforms to OnField, OnType.

Steers the synthesized encode and decode. On a field, @Codec { name = "user_id" } writes the field under that name, @Codec { skip = true } leaves it out (it reads as null, so it is an optional); on an enum, @Codec { tag = "kind" } writes a variant as a struct holding the tag beside the payload's fields (internally tagged); on a struct or a class, @Codec { rename = .SnakeCase } rewrites every field's name and @Codec { denyUnknown = true } refuses a field the data has and the type has not.

Fields

pub name: string = ""
pub skip: bool = false
pub tag: string = ""
pub rename: Case = .Same
pub denyUnknown: bool = false