rust-embedded / rust-embedded/embedded-hal-mock
Support for don't care writes in I2C
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 146
- Forks
- 29
- PR merge metrics
- No merged PRs in 30d
Description
Motivation
I have a test case where there are a ton of I²C writes which I don't care about in this specific test. I still want to mock execute them but the data written is not relevant.
Implementation
I have some ideas how this could be implemented.
-
The
impl Transactionblock 1 could be extended with a functionwrite_ignorethen either implemented by extending the enumMode2 withWriteIgnoreor a new field in theTransactionstruct3 -
Another way would be to add an option to
write()4 but that would break all tests for every user of the I²C whether they want this feature or not, so I don't think that is the path forward. -
The same builder style interface as
with_error5 could be used to modifyTransaction
- Are there any negative implications I did not consider?
- Any preferred implementation style?
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 in src/eh1/i2c.rs, reading the impl Transaction block, Mode, Transaction, and the with_error builder referenced in the issue. Compare the proposed ways to represent an ignored write, then add coverage showing that I2C writes can execute without matching their data while existing write expectations remain unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100