Skip to content

runtime adapter: define each message kind's code once #665

Description

Follow-up to #640.

The runtime adapter's framing, in tests/runtime-adapter/src/frame.rs, writes each message kind's code as a bare number twice: Kind::from_code maps a header's kind byte to a Kind, and Kind::code maps a Kind back to its byte. Adding or renumbering a kind means keeping both matches in step by hand.

Give each code a single definition that both directions use, for example:

  • named constants for the codes;
  • explicit discriminants on a #[repr(u8)] Kind, so that code is a cast and from_code matches the same values; or
  • a small, maintained crate that derives the conversion from u8, as long as the guest-only build stays free of host-only dependencies, which tests/independent_build.rs checks.

Done when:

  • each kind's code is written once in frame.rs;
  • the table of kinds in tests/runtime-adapter/README.md still matches the codes;
  • the adapter's checks pass in every configuration, as its README lists them.

Activity

  1. akhil9tiet commented on Oct 21, 2026

    @akhil9tiet
    Contributor

    I'd like to work on this — please assign it to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions