@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.
@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.