Module serialisation
Expand description
Per-type serialise / deserialise helper generation for workers mode (v0.8 §3.4 / §5.2).
Every Bynk type that crosses a context boundary needs:
serialise_<Type>(value): JsonValue— structural lowering.deserialise_<Type>(json): Result<<Type>, BoundaryError>— structural validation + refinement re-validation, then a nominal cast back to the receiving context’s view.
Helpers live in the owning module — commons modules emit helpers for commons types, context modules emit helpers for the types they declare.
Enums§
Functions§
- collect_
boundary_ types - Compute the set of type names (transitively reachable) that need serialise/deserialise helpers for this context: any type used in the argument or return position of a service handler exposed by this context, walked through record fields, sum payloads, and the generic type parameters of Result/Option/Effect.
- collect_
codec_ closure - v0.22b: the codec closure for a set of
Json.encode/Json.decode[T]target type-refs — the named types needing per-type helpers (transitively through record fields and sum payloads) plus the generic instantiations needing specialised helpers. The same closure logic as the boundary collectors, rooted at expressions instead of service signatures. - collect_
generic_ instantiations - Collect the set of
Result<A, B>/Option<A>instantiations used in boundary positions so the emitter can synthesise the specialised helpers. v0.18: an instantiation may also appear in the fields of a boundary record or sum payload (e.g. the bynk surface’sRequest.contentType: Option[String]) — the per-type serialisers delegate to the specialised generic helpers, so walk those too. - deserialise_
expr - v0.22b: an expression-form deserialise call for a codec target. Named types and generic instantiations go through their (module-local) helpers; bases inline the structural check.
- emit_
generic_ helpers - Emit specialised helpers for each
Result<A, B>/Option<A>instantiation. They delegate to the named-type serialisers for A and B. - emit_
helpers_ for_ owner - Emit
serialise_<T>anddeserialise_<T>for every named type the owner declares that crosses a boundary.owner_qualifiedis the qualified name used as the brand path so that refinement-violation messages identify the origin context. - serialise_
expr - v0.22b: an expression-form serialise for a codec target — the same dispatch as a record field’s serialisation.