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

Refactor ::serve to multiple variants #347

Closed
wants to merge 1 commit into from
Closed

Refactor ::serve to multiple variants #347

wants to merge 1 commit into from

Conversation

silvanshade
Copy link
Contributor

@silvanshade silvanshade commented Jun 23, 2022

@ebkalderon This PR refactors the Server::serve function into multiple variants, one of which allows for passing a I: Stream<Item = Message> and O: Sink<Message> rather than just I: AsyncRead and O: AsyncWrite.

This change was motivated by my experience working with tower-lsp for a wasm target in the tower-lsp-web-demo project and is also relevant to #341.

Since in that case no data was actually be processed over stdin/stdout, there was no real justification to use byte-based framed IO with messages delimited by Content-Length headers, and a significant amount of code was needed just to convert from the underlying web ReadableStream and WritableStream based data structures used internally for server client communication into something that could interface with tower-lsp.

With this PR, instead I could simply use Server::serve_messages from tower-lsp for that project.

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.

1 participant