Skip to content

refactor!: Unify PendingRequest and clean up API#10

Open
evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
evanlinjin:api_cleanup
Open

refactor!: Unify PendingRequest and clean up API#10
evanlinjin wants to merge 3 commits intobitcoindevkit:masterfrom
evanlinjin:api_cleanup

Conversation

@evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Jan 30, 2026

Summary

Eliminate duplicated AsyncPendingRequest/BlockingPendingRequest 21-variant enums and clean up the public API.

Type erasure (4509768)

Replace the two parallel pending request enums with a single PendingRequest struct that uses a Box<dyn FnOnce + Send + Sync> handler for closure-based type erasure. This:

  • Makes RequestTracker (formerly State) non-generic
  • Collapses AsyncBatchRequest/BlockingBatchRequest into a single BatchRequest
  • Removes all async/blocking-specific type aliases for response channels
  • Adds BatchRequest::request_async() and request_blocking() convenience methods that create channels internally and return receivers

Naming and module cleanup (0f4c565)

  • Type renames: StateRequestTracker, SatisfiedRequestCompletedRequest, ErroredRequestFailedRequest, RawNotificationOrResponseRawIncoming, MaybeBatchRawOneOrMany
  • Method renames: process_incominghandle_incoming, into_satisfiedinto_completed, into_erroredinto_failed
  • Dead code removed: BatchRequestError (no longer referenced after the type erasure refactor)
  • Module restructure: merged batch_request.rs into pending_request.rs, extracted wire types from lib.rs into protocol.rs, renamed state.rsrequest_tracker.rs

Client module separation (d9521fe)

  • Moved async/blocking type aliases from lib.rs into client module
  • Deleted 4 unused aliases: AsyncEventSender, AsyncRequestReceiver, BlockingRequestReceiver, BlockingEventSender
  • client is now pub mod — non-re-exported types available via electrum_streaming_client::client::*
  • Only AsyncClient, BlockingClient, and their error types are re-exported at the crate root

Breaking changes

  • All renamed types and methods listed above
  • AsyncBatchRequest / BlockingBatchRequest replaced by unified BatchRequest
  • AsyncPendingRequest / BlockingPendingRequest replaced by unified PendingRequest
  • State is now RequestTracker and is no longer generic
  • AsyncRequestSender, AsyncEventReceiver, BlockingRequestSender, BlockingEventReceiver moved from crate root to client module

@evanlinjin evanlinjin marked this pull request as draft January 30, 2026 05:04
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>
@evanlinjin evanlinjin changed the title feat!: Unify PendingRequest via closure-based type erasure refactor!: Unify PendingRequest and clean up API Jan 30, 2026
…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>
@evanlinjin evanlinjin marked this pull request as ready for review January 30, 2026 10:28
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>
Copy link
Member Author

@evanlinjin evanlinjin left a comment

Choose a reason for hiding this comment

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

self-ACK d9521fe

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.

1 participant