Changes
- [Stream] Use
ConnectionInfo
to simplify TCP stream creation and configuration. In addition, theConnectionInfoProvider
trait ensures cleaner stream composition API.
For example, before the change, when creating Websocket
using composition we would need to reference server_name
in multiple places.
let mut ws = TcpStream::bind_and_connect("stream.binance.com:9443", None, None)?
.into_tls_stream("stream.binance.com")
.into_websocket("wss://stream.binance.com:9443/ws");
After the change, the Websocket
creation looks much simpler.
let mut ws = TcpStream::try_from(("stream.binance.com", 9443))?
.into_tls_stream()
.into_websocket("/ws");