WorkerLib.Type (serify v0.1.0)

Copy Markdown View Source

One data type: a model, and the formats whose functions speak it.

model is the module the format functions take and return — anything with from_field_map/1 and to_field_map/1, which use WorkerLib.Serify.Model generates. serify converts on either side, so the field map never reaches the worker:

%Type{model: LedgerEntry, formats: %{
  "binary" => {&LedgerEntry.marshal/1, &LedgerEntry.unmarshal/1}}}

model: nil is the other path, for a type with no natural struct (the audit fixtures mutate a field map on purpose): the functions then take and return the field map itself.