oxidecomputer / oxidecomputer/hubris
counters: want to be able to count multiple fields of a variant
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 239
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 23
Description
Sometimes a variant of an enum that derives Count has multiple fields which both can and should be counted --- for example, see https://github.com/oxidecomputer/hubris/pull/1742#discussion_r1556483876, where we have a variant like:
enum Trace {
// ...
I2cError {
txn: I2cTxn,
#[count(children)] code: i2c::ResponseCode,
}
// ...
}
where I2cTxn is also an enum that derives Count. It would be nice to be able to generated a doubly-nested set of counters, so that we can count the I2C error code separately for each transaction type. Currently, the derive(Count) attribute can't do that. It would be nice if it could.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the derive(Count) implementation and the #[count(children)] handling described in this issue, then review the linked pull-request discussion for the motivating I2cError shape. Determine how multiple counted fields should produce nested counters, and consider the work complete when an enum variant can count both its transaction and response-code fields separately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100