atproto_codegen/emit/union

Open-union synthesis: a named type per union field with one variant per ref plus Other(Dynamic), $type-dispatching codecs included.

The three parts (type, encoder, decoder) are returned separately rather than as one joined string: the types plugin renders the first two, the decode-json plugin the third, and the host interleaves them with the def’s own type/encoder/decoder so the emitted file matches the order the monolithic emitter used to produce.

Types

pub type UnionParts {
  UnionParts(type_def: String, encoder: String, decoder: String)
}

Constructors

  • UnionParts(type_def: String, encoder: String, decoder: String)

Values

pub fn emit_union(
  cfg: config.Config,
  nsid: String,
  name: String,
  refs: List(String),
) -> UnionParts

An open union: one variant per ref plus Other(Dynamic), which round-trips unrecognized $types untouched instead of destroying them.

Search Document