Repository navigation
Conversation
Generate descriptor-checked closed selectors, payload selectors and borrowed adapters through explicit build, plugin or schema configuration. Keep native declarations separate from portable output and retain caller ownership of borrowed buffers and capabilities. Validate complete mappings, legacy normalization, external registrations, restricted type paths and output destinations. Include fixed typed diagnostics, typed option bindings, documentation and native/no_std/WASM compatibility tests without changing upstream versions or compiler policy.
|
All contributors have signed the CLA ✍️ ✅ |
Keep output filenames portable by rejecting case-insensitive Windows device stems even when followed by .rs. Use the existing fixed InvalidOutput reason for selector, payload and borrowed adapters without changing valid output. Test all documented numbered device stems, mixed case and nearby valid names. All 18 adapter tests and strict pinned Clippy pass. The library also compiles as a downstream dependency with Rust 1.75; preserve upstream versions and lock.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Downstream libraries sometimes need a process-local Rust API alongside their portable protobuf model: selectors that reject unspecified and unknown values, selectors with validated value payloads, and borrowed inputs with callback or provider references. COSE currently maintains parallel enum-generation scripts to preserve those signatures, which makes schema changes easy to miss.
This adds a generic, opt-in adapter generator so the descriptor and explicit metadata define those native declarations together.
Changes
(buffa.ext.file).adaptersoptions, the RustAdapterConfigAPI, and a strict JSON representation capped at 1 MiB.buffa_build::Config::generate_adapters(true)andadapters=true; explicit Rust configurations andadapter_manifest=<path>also work independently.EnumValue::Unknowncarrying a recognized number. Legal numeric aliases are supported.GeneratedFileKind::Adapterfiles. Applications include them in their native API modules and retain control of module feature gates. Portable package trees exclude adapter files, and normalized output collisions and reserved Windows device filenames are rejected before writes on every host.Descriptor shape, source coverage, path syntax and Copy bounds are checked mechanically. Application-supplied Rust type bindings, opaque value invariants, domain validation, cryptographic implementations and policy remain application responsibilities; the guide states this boundary explicitly.
Compatibility and validation
Adapter generation defaults to off. Tests compare portable output with the feature off and on, and preserve wire/JSON names. The COSE fixture covers 17 closed selectors, two payload selectors and five borrowed adapters, including legacy inputs, external identifiers, caller-buffer identity, callbacks, and lifetime/Debug compile-fail checks. The generator contains no COSE-specific algorithm or policy tables.
Validated against upstream main without other feature branches:
wasm32-unknown-unknowncompilation, and an edition-2024 consumer build. Regressions include legal primitive-name shadowing and raw keyword module paths.Upstream package versions, MSRV 1.75 and the pinned development toolchain remain unchanged. The generator adds a dependency on
buffa-proto-optionsand reuses workspace Serde dependencies for metadata. At release preparation, the codegen dependency floor must advance to the release containing the new option types so published consumers receive matching bindings.The larger diff is primarily the checked-in generated option bindings and compatibility fixtures. The implementation and guide are in
buffa-codegen/src/adapters/anddocs/native-adapters.md.