Writing enums: pre_assert?
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 853
- Forks
- 56
- PR merge metrics
- No merged PRs in 30d
Description
I have code like this:
```
#[derive(BinRead, BinWrite, Debug)]
#[brw(import(message_type: u8))]
enum MessageData {
#[br(pre_assert(message_type == 0x0u8))] Nil {
},
...
}
```
`bw` / `brw` don't allow `pre_assert` so they can't serialize this. Is there a way to reverse parsing an enum like this? Is it feasible to implement `pre_assert` for `brw`?... I don't _think_ using `assert` is correct.
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
No repository file or test is named. Start by tracing how enum attributes such as #[br(pre_assert(...))] and #[brw(...)] are handled, then compare the parsing and writing paths. Done means determining whether pre_assert can support brw serialization and documenting or testing the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100