Repository navigation
feat(io): add a sans-io byte decoder - #59
Draft
evanlinjin wants to merge 2 commits into
Draft
evanlinjin wants to merge 2 commits into
evanlinjin wants to merge 2 commits into
Conversation
`io::Decoder` turns bytes into `RawIncoming`s with no reader attached, and `io::encode` turns requests into bytes, so a custom transport only moves bytes. `ReadStreamer` and the write helpers now use them. `ReadStreamer` no longer panics when the reader ends partway through a line: it yields an `UnexpectedEof` error. An invalid line yields an error and decoding carries on with the next one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`blocking_write`, `async_write` and `tokio_write` were each `writer.write_all(&encode(msg))`. The clients now call that directly, and so can users. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #59 +/- ##
==========================================
+ Coverage 48.33% 53.55% +5.21%
==========================================
Files 11 11
Lines 902 943 +41
Branches 18 20 +2
==========================================
+ Hits 436 505 +69
+ Misses 461 433 -28
Partials 5 5
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Adds
io::Decoder, a sans-io decoder for Electrum's line-delimited JSON-RPC:feed(&[u8])the bytes as they arrive, then iterate it forRawIncomings (a batch yields one per message). Withio::encodefor the other direction, a custom transport only has to move bytes instead of reimplementing line splitting and parsing.ReadStreamernow usesDecoder, so there's one copy of the framing logic.Breaking:
io::blocking_write,io::async_writeandio::tokio_writeare removed. Each was justwriter.write_all(&encode(msg)); call that instead.Behaviour changes in
ReadStreamer:UnexpectedEoferror. It used to panic onassert_eq!(b, b'\n').🤖 Generated with Claude Code