Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support generic streams #2

Merged
merged 2 commits into from
Aug 27, 2018
Merged

Support generic streams #2

merged 2 commits into from
Aug 27, 2018

Conversation

lux01
Copy link
Contributor

@lux01 lux01 commented Aug 17, 2018

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.

@SLMT
Copy link
Owner

SLMT commented Aug 18, 2018

Great! Thanks for your contribution! I will check it these days.

Copy link
Owner

@SLMT SLMT left a comment

Choose a reason for hiding this comment

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

It looks great for me. Good enhancement !

@SLMT SLMT merged commit a8cd43c into SLMT:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants