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:
- FIFO pipes. Eg. named pipes mkfifo(3) and unnamed pipes pipe(2).
- Sockets. Eg. TCP connections and UNIX domain sockets unix(7).
- Character devices. Eg. tty(4) or pty(7).
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
- Locked stdin for asynchronous read.
- Locked stdout for asynchronous read.