Module async_lsp::stdio

source ·
Expand description

Utilities to deal with stdin/stdout communication channel for Language Servers.

Typically Language Servers serves on stdin/stdout by default. But generally they cannot be read or written asynchronously usually, due to technical reasons. (Eg. tokio::io::stdin delegates reads to blocking threads.)

This mod defines PipeStdin and PipeStdout for only stdin/stdout with pipe-like backends, which actually supports asynchronous reads and writes. This currently means one of:

When calling PipeStdin::lock, it locks the stdin using std::io::stdin, set its mode to asynchronous, and exposes an AsyncRead interface for asynchronous reads. It keeps the lock guard internally, and reset the mode back when dropped, so that you can use println! as normal after that. PipeStdout::lock works in class.

Structs