refactor: update and turn `WsTransportClientBuilder` generic (#1168)
* refactor(jsonrpsee-client-transport): update and turn `WsTransportClientBuilder` generic
- fix(docs): typo on `WsTransportClientBuilder` doc on `Receiver`
reference.
- refactor: add initial fn signatures for `build_with_stream`,
`try_connect_over_tcp`, and `try_connect`.
- refactor: expose `EitherStream` visibility to public.
- refactor: make `Sender` and `Receiver` generic over T, a data stream.
- refactor: make `TransportSenderT` and `TransportReceiverT`
implementations over generic `Sender` and `Receiver`, bound to
`AsyncRead`, `AsyncRead`, `MaybeSend` and `'static`.
- refactor: turn old `try_connect` TCP steps into
`try_connect_over_tcp`.
- feat: implement `build_with_stream` and `try_connect` to handle and
handle the handshake for a generic data stream `T`.
- feat: add new `Redirected` error variant to `WsHandshakeError`, as it
should be handled by the client when using a generic data stream `T`.
- TODO(@oleonardolima): Add new tests that uses a different data stream.
* refactor(jsonrpsee-ws-client): add new fns to `WsClientBuilder`
- feat: add new `WsClientBuilder::build_with_transport` that builds and
returns a `WsClient` with the given `Sender` and `Receiver`.
- feat: add new `WsClientBuilder::build_with_stream` that uses the new
`WsTransportClientBuilder::build_with_stream`, building and returning
the `WsClient` with the given `data_stream` as transport layer.
- refactor: update the `WsClientBuilder::build` to use the new
`build_with_transport`, it helps not having duplicated code.
* refactor: re-export `EitherStream` & sort current list
* test: add integration tests and helper fns
- add new helper fns to spawn a socks5 server, using `fast-socks5`
- add new helper enum for `DataStream` that acts as a wrapper to
`Socks5Stream<T>`, similar to what a client would need to do.
- impl AsyncRead + AsyncWrite for the helper `DataStream` enum, to make
it compatible between futures::io and tokio::io.
- add new tests that connects over a socks5 proxy, and use the new
`WsClientBuilder::default()::build_with_stream(...) fn.
* address review suggestions
---------
Co-authored-by: Niklas Adolfsson <[email protected]>
Please register or sign in to comment