refactor!: Unify PendingRequest and clean up API#10
Open
evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
Open
refactor!: Unify PendingRequest and clean up API#10evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
Conversation
Eliminate the duplicated AsyncPendingRequest/BlockingPendingRequest 21-variant enums by replacing them with a single concrete PendingRequest struct that uses a Box<dyn FnOnce> handler to type-erase the response dispatch logic. This makes State non-generic, collapses AsyncBatchRequest/BlockingBatchRequest into a single BatchRequest, and removes all async/blocking-specific type aliases for response channels. BatchRequest gains request_async() and request_blocking() convenience methods that create channels internally and return receivers, so callers no longer need to wire up channels manually. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
45ed3ac to
4509768
Compare
…ules - Rename types: SatisfiedRequest → CompletedRequest, ErroredRequest → FailedRequest, RawNotificationOrResponse → RawIncoming, MaybeBatch → RawOneOrMany, State → RequestTracker - Rename methods: process_incoming → handle_incoming, into_satisfied → into_completed, into_errored → into_failed - Add request_async/request_blocking convenience methods to BatchRequest - Remove dead BatchRequestError type - Merge batch_request.rs into pending_request.rs - Extract wire types from lib.rs into protocol.rs - Remove Mutex from PendingRequest in favor of Send + Sync bounds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
c553b85 to
0f4c565
Compare
Move async/blocking type aliases from lib.rs into the client module. Delete 4 unused aliases (AsyncEventSender, AsyncRequestReceiver, BlockingRequestReceiver, BlockingEventSender). Re-export only the client structs and error types at the crate root. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
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.
Summary
Eliminate duplicated
AsyncPendingRequest/BlockingPendingRequest21-variant enums and clean up the public API.Type erasure (
4509768)Replace the two parallel pending request enums with a single
PendingRequeststruct that uses aBox<dyn FnOnce + Send + Sync>handler for closure-based type erasure. This:RequestTracker(formerlyState) non-genericAsyncBatchRequest/BlockingBatchRequestinto a singleBatchRequestBatchRequest::request_async()andrequest_blocking()convenience methods that create channels internally and return receiversNaming and module cleanup (
0f4c565)State→RequestTracker,SatisfiedRequest→CompletedRequest,ErroredRequest→FailedRequest,RawNotificationOrResponse→RawIncoming,MaybeBatch→RawOneOrManyprocess_incoming→handle_incoming,into_satisfied→into_completed,into_errored→into_failedBatchRequestError(no longer referenced after the type erasure refactor)batch_request.rsintopending_request.rs, extracted wire types fromlib.rsintoprotocol.rs, renamedstate.rs→request_tracker.rsClient module separation (
d9521fe)lib.rsintoclientmoduleAsyncEventSender,AsyncRequestReceiver,BlockingRequestReceiver,BlockingEventSenderclientis nowpub mod— non-re-exported types available viaelectrum_streaming_client::client::*AsyncClient,BlockingClient, and their error types are re-exported at the crate rootBreaking changes
AsyncBatchRequest/BlockingBatchRequestreplaced by unifiedBatchRequestAsyncPendingRequest/BlockingPendingRequestreplaced by unifiedPendingRequestStateis nowRequestTrackerand is no longer genericAsyncRequestSender,AsyncEventReceiver,BlockingRequestSender,BlockingEventReceivermoved from crate root toclientmodule