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

feat(buffer): add from_parts and into_parts functions #1107

Merged
merged 1 commit into from
Mar 30, 2017

Conversation

illegalprime
Copy link

this adds the ability to deconstruct a buffer into all of its parts
and the ability to create a buffer from all of its parts, this lets
users deconstruct the buffer, edit the reader, then build it back up
again without losing any information

Currently a whole heap of changes is coming to rust-websocket, some of the changes require that we handle streams generically and therefore we need better interoperability with other buffered reader implementations. The large changes (which had to be done all at once) are in cyderize/rust-websocket#80, and include the ability to upgrade a hyper request to a websocket connection.

this adds the ability to deconstruct a buffer into all of its parts
and the ability to create a buffer from all of its parts, this lets
users deconstruct the buffer, edit the reader, then build it back up
again without losing any information
@seanmonstar seanmonstar merged commit 48dea98 into hyperium:0.10.x Mar 30, 2017
@seanmonstar
Copy link
Member

Ok!

illegalprime added a commit to illegalprime/rust-websocket that referenced this pull request Mar 31, 2017
illegalprime added a commit to illegalprime/rust-websocket that referenced this pull request Apr 1, 2017
illegalprime pushed a commit to websockets-rs/rust-websocket that referenced this pull request Apr 1, 2017
…date deps, and much more.

* adds a common stream interface that is simpler than WebsocketStream

* integrated new Stream trait and IntoWs struct

* Fixed client creation with new stream trait

Changes the way clients are created slightly:
 - (slightly, ostensibly) better performance when one knows if they want
   a secure connection or not. This means no match statement redirecting
   calls to their respective SSL or TCP stream.
   These calls have been named:
    - `connect` for insecure connections
    - `connect_secure` for secure connections

 - If one does not know how which connection it wants it can take the
   (not verified by testing) performance hit of putting the underlying
   stream on the heap behind a `Box`. This can be done with:
    - `connect_agnostic`

All calls currently take the custom ToWebSocketUrlComponents but that
should be changed to a `Url` (probably from rust-url).

* started work on having the server side code use websocket upgrade

* server now uses the ws upgrade trait to create clients

* IntoWs for Streams & Request/Stream pairs

Both streams and request/stream pairs can be made into a WsUpgrade
struct. also AsTcpStream streams have a method to access the inner tcp
stream. Things left:

 - Finish WsUpgrade struct: add methods and ability to accept or reject
   connections.
 - Implement IntoWs for a hyper serverside request.

* started on hyper IntoWs integration

The last bit is to extract the NetworkStream from a hyper server-side
request and save that as a Stream, then turn it into an Incoming<(..)>
and validate the request.

Implementing Stream for a NetworkStream is proving complicated, since
because now there is conflicting implementations for many structs
implementing NetworkStream.

* removed TryUnsizedClone and many Stream impls for a simpler model where all AsTcpStreams implement Stream

* removed response and request from the server code in favor of WsUpgrade

* moved hyper-specific upgrade implementation into its own module

* implemented AsTcpStream for Box<AsTcpStream>

This was initially very hard because one cannot clone unsized types and
put them on the stack. I was about to revert to WebSocketStream style
enum-variant-per-sized-type style but I managed to live another day
without all those match blocks.

* Steps toward implementing IntoWs for Hyper request

The validation is done, now the only work is to extract the underlying
stream.

* sender and receiver not holding the stream anymore, client uses stream

* added back splitting and shutting down client

* started working on builder

* finished builder pattern and removed unused modules

* implement intows for hyper request, cleanup and refactoring

* moved client builder into its own module

* implemented intows

* added TCP settings functions and verified questions about ws protocol

* updated all dependencies to the latest and greatest

* made openssl optional behind a feature gate

* pass all current tests with warnings

* tests pass without warnings

* fleshed out roadmap, fixes #27

* added standard style enforced by the CI

* added buffering reads and writes to roadmap

* version bump to 0.18.0: major API change

* easier wsupgrade api for protocols/exts, ability for client to verify protocols, etc.

* changed stream trait to impl Read and Write, not contain

* keep track of all the used buffers in BufReaders so no data goes missing

this is possible with the help of hyperium/hyper#1107

* docs and doc tests
@illegalprime
Copy link
Author

@seanmonstar I'm ready to publish the shiny new websockets crate but I can't until this change gets published in a hyper version, I was wondering what the timeline is for that? Thanks!

@seanmonstar
Copy link
Member

Published v0.10.6 with this change. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants