Skip to content

Conversation

@cbiffle
Copy link
Contributor

@cbiffle cbiffle commented Dec 10, 2025

This probably doesn't work yet, we're waiting for confirmation from Renesas.

This is preparing for adding more variants to SupportedDevices. The list
of SupportedDevices was present, explicitly or implicitly, in several
places in the code:

- The enum definition itself
- A list of strings used to filter device names
- A set of match statements used to convert those strings into variants
  of the enum
- Error messages listing support device types, which hardcoded the
  variant names.
- A Display impl that repeated the names.

This was noisy and potentially error-prone. I have simplified it by
applying the `strum` crate to derive traits for the SupportedDevice
macro:

- `FromStr` (derived by EnumString) eliminates all handrolled parsing
  and match code
- `VariantNames` (derived by EnumVariantNames) allows the error messages
  to list expected names without hardcoding them
- `Display` can now be derived automatically.

I chose `strum` because of its option to make string comparisons
case-insensitive, which neatly covers this command's use case of
converting lowercase manifest device names into uppercase enum variants.
This contains a bunch of assumptions (marked with TODOs) and may not
work. We are reaching out to Renesas for clarifications.
@cbiffle cbiffle force-pushed the cbiffle/cosmo-rendmp branch from 13112e2 to e3c0a76 Compare December 10, 2025 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants