Skip to content

Codegen by language

Status: sketch — worked examples of the source one schema should produce in each language (codegen, not the libgen packaging around it). Not normative; rust is the only generator implemented today (see Generating code).

From this schema:

struct Message {
    receiver: string
    subject: string
    message: string
}

Compiled languages

trait Message {
    fn receiver(&self) -> String;
    fn subject(&self) -> String;
    fn message(&self) -> String;
}

Dynamic languages

class Message(Protocol):
    receiver: str
    subject: str
    message: str
export interface Message {
    receiver: string;
    subject: string;
    message: string;
}

Implemented (generation#4, comline-typescript#5, #8) — struct becomes export interface; error an export interface (wire payload) plus an export class <Name>Error throwable; enum an export enum with string values. A protocol emits the full RPC shape against @comline/runtime: an IR_HASH (the canonical schema_ir_hash, so a TS peer and a Rust peer agree), <Proto><Fn>Params interfaces, a provider interface of Promise-returning methods, a <PROTO>_CALLS table, a <Proto>Dispatcher, a <Proto>Client (+ static connect), and a serve<Proto> helper — framing from @framing / the package default. lib mode (comline-typescript#9) wraps the per-schema output in an npm package — package.json (declaring @comline/runtime), tsconfig.json, and a src/index.ts barrel.

type Message = {
    receiver: string,
    subject: string,
    message: string,
}