Skip to content

IO implementation for embedded-io, rebased and updated#126

Open
tshakah wants to merge 7 commits intorust-embedded:mainfrom
seagen-io:io-mock
Open

IO implementation for embedded-io, rebased and updated#126
tshakah wants to merge 7 commits intorust-embedded:mainfrom
seagen-io:io-mock

Conversation

@tshakah
Copy link

@tshakah tshakah commented Mar 19, 2025

This is just a rebase of #101 with most of the review comments applied, as I went to use embedded-hal-mock for a test today and found I needed those features.

The only difference from the review is I phrased the optional feature sentence a little differently:
Async is supported with the optional embedded-hal-async feature.

@tshakah tshakah changed the title Io mock IO implementation for embedded-io, rebased and updated Mar 19, 2025
This applies _most_ of the final comments from the review on
rust-embedded#101. I phrased one of
the changes slightly differently.
@ryankurte
Copy link
Contributor

looks good to me! just need to bump the rust version we're testing from 1.75.0 to 1.81.0, which seems fine.

@tshakah
Copy link
Author

tshakah commented Feb 27, 2026

I've updated CI to run 1.81

Copy link

@asasine asasine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of changes for correctness but not gonna block do just comments

Comment on lines +240 to +246
let len = transaction.response.len();
buffer[..len].copy_from_slice(&transaction.response[..len]);

match transaction.expected_err {
Some(err) => Err(err),
None => Ok(len),
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't match up with the comment on with_error. The expectation response buffer is copied into the buffer argument, even if there's an error.


#[tokio::test]
#[cfg(feature = "embedded-hal-async")]
async fn test_async_spi_mock_write() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spi looks out of place in this test name.

Comment on lines +675 to +676
let err = io.read(&mut [10, 12]).unwrap_err();
assert_eq!(err, ErrorKind::ConnectionReset);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be an assert added here that the mutable slice argument remains unmodified.

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.

4 participants