Commit ab4fcb1
committed
Merge #10: refactor!: Unify PendingRequest and clean up API
d9521fe refactor!: Move client type aliases into client module (志宇)
0f4c565 refactor!: Clean up API naming, remove dead code, and restructure modules (志宇)
4509768 feat!: Unify PendingRequest via closure-based type erasure (志宇)
Pull request description:
## 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**: `State` → `RequestTracker`, `SatisfiedRequest` → `CompletedRequest`, `ErroredRequest` → `FailedRequest`, `RawNotificationOrResponse` → `RawIncoming`, `MaybeBatch` → `RawOneOrMany`
- **Method renames**: `process_incoming` → `handle_incoming`, `into_satisfied` → `into_completed`, `into_errored` → `into_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.rs` → `request_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
ACKs for top commit:
evanlinjin:
self-ACK d9521fe
Tree-SHA512: f99268135aab474befe2a866a5fd9ef067c2bb3d8aef6f14ccc49abbfb79aadd1669cb340563abe159293c7d0976138a76ed962d28af3ff09b546b8f94f721a39 files changed
Lines changed: 570 additions & 856 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 31 | + | |
36 | 32 | | |
37 | 33 | | |
38 | 34 | | |
| |||
This file was deleted.
0 commit comments