Refactor ::serve to multiple variants #347
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@ebkalderon This PR refactors the
Server::serve
function into multiple variants, one of which allows for passing aI: Stream<Item = Message>
andO: Sink<Message>
rather than justI: AsyncRead
andO: 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 webReadableStream
andWritableStream
based data structures used internally for server client communication into something that could interface withtower-lsp
.With this PR, instead I could simply use
Server::serve_messages
fromtower-lsp
for that project.