This PR allows users to costruct a new Telnet object without having to implicitly use a TcpStream. This is to allow users to provide their own streams which is useful if they want to, for example, unit test code that interacts with Telnet, or wrap their TcpStream in TLS.
This is accomplished by introducing a new trait Stream which is Read + Write and captures the interface from TcpStream implicitly used by the Telnet client. The cost of this is that stream we now use dynamic dispatch to interact with the stream.
This could be avoided by making Telnet generic over the type of stream but this would change the external interface.
This PR allows users to costruct a new
Telnet
object without having to implicitly use aTcpStream
. This is to allow users to provide their own streams which is useful if they want to, for example, unit test code that interacts with Telnet, or wrap their TcpStream in TLS.This is accomplished by introducing a new trait
Stream
which isRead + Write
and captures the interface fromTcpStream
implicitly used by theTelnet
client. The cost of this is thatstream
we now use dynamic dispatch to interact with the stream.This could be avoided by making
Telnet
generic over the type ofstream
but this would change the external interface.