Skip to main content

Crate phon_codegen

Crate phon_codegen 

Source
Expand description

The codegen tool.

phon schemas originate from Rust types via facet; codegen turns those schemas into source for the other languages a system speaks. For each target it emits two things: the type definitions a programmer writes against, and the schema itself as a constant — the self-describing phon bytes of the Schema value, which the peer parses at startup. A non-Rust peer never re-derives a schema from its generated types; the emitted bytes are the source of truth, so its SchemaId matches the Rust origin exactly (r[codegen.schema-is-source-of-truth]).

This is the data plane codegen: types + schemas + ids. The RPC layer (services, clients, dispatchers, channels) is generated separately by the framework on top of this output.

Spec: docs/content/spec.md — “Codegen”.

Re-exports§

pub use source::Builder;
pub use source::Module;
pub use source::Root;

Modules§

source
The codegen input: a set of root Rust types, resolved (via the facet bridge) into one schema registry plus the roots’ content-derived ids.
targets
typescript
TypeScript target: emit the ergonomic type declarations a programmer writes against, plus the self-describing schema-bytes the peer parses at startup.