Catch WouldBlock alongside TimedOut in Serial::Port's read_byte - #61
Merged
Conversation
The Port branch of read_byte only mapped ErrorKind::TimedOut to Ok(None), unlike the Tcp branch which also catches WouldBlock. Some serialport backends report a timed-out read as WouldBlock, which used to surface as an Err here instead of honoring the documented Ok(None) timeout contract.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #51
Summary
Serial::read_byte'sPortvariant only mappedErrorKind::TimedOuttoOk(None), unlike theTcpvariant which also catchesErrorKind::WouldBlock. Someserialportbackends report a timed-out read asWouldBlockrather thanTimedOut, which used to surface asErrhere, breaking the documented "Ok(None)means nothing arrived in time, not an error" contract.WouldBlockto thePortbranch's match guard, matching theTcpbranch.Test plan
WouldBlockPorttest stub implementingserialport::SerialPortwhosereadalways returnsErrorKind::WouldBlock, and a regression test assertingread_bytereturnsOk(None)for it.cargo test -p nucleus-test-sdk --lib— 9 passed.cargo clippy -p nucleus-test-sdk --all-targets -- -D warnings— clean.cargo fmt --all -- --check— clean.Generated by Claude Code