From 9dc48d8208f46e03961659b454d0efac7055496c Mon Sep 17 00:00:00 2001 From: Kinflou Date: Wed, 2 Sep 2026 15:28:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(codegen):=20GenRequest.default=5Fframing?= =?UTF-8?q?=20=E2=80=94=20consumer=20framing=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A generator can now be told a fallback wire framing to apply to any protocol that does not select one itself with `@framing`. The CLI fills it from `comline.toml`'s `[generate] default_framing`; `None` keeps each generator's built-in default (datagram for Rust). Opaque to the contract crate — the value is just a framing name string the target generator recognises and validates. conformance: the shared `request()` helper passes `default_framing: None`. --- codegen/src/lib.rs | 6 ++++++ conformance/tests/conformance.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/codegen/src/lib.rs b/codegen/src/lib.rs index 3669736..b38a967 100644 --- a/codegen/src/lib.rs +++ b/codegen/src/lib.rs @@ -43,6 +43,12 @@ pub struct GenRequest<'a> { pub mode: Mode, pub schemas: &'a [(String, Vec)], pub package: PackageMeta, + /// Consumer-set fallback wire framing (`comline.toml`'s + /// `[generate] default_framing`), applied by a generator to any protocol + /// that does not pick one itself with `@framing`. `None` ⇒ the generator's + /// built-in default. The value is a framing name the generator recognises + /// (`"jsonrpc"`, `"datagram"`, …); an unknown one falls back to the default. + pub default_framing: Option, } /// A code generator: frozen IR in, generated files out. diff --git a/conformance/tests/conformance.rs b/conformance/tests/conformance.rs index 386b9a3..c8da0c4 100644 --- a/conformance/tests/conformance.rs +++ b/conformance/tests/conformance.rs @@ -39,6 +39,7 @@ fn request(schemas: &[(String, Vec)]) -> GenRequest<'_> { name: "conformance".to_string(), version: "0.0.0".to_string(), }, + default_framing: None, } }