src/lsp/transport/stdio.bend relies on unsafe/foreign
raw source on the hub · import bolt@1.17.0.0/src/lsp/transport/stdio.bend as Stdio
transport/stdio: LSP's base protocol over stdin and stdout. Reads bytes (a read may end inside a UTF-8 char, and Content-Length counts bytes), keeps what is past the current message in buf.
3 imports
import Base import ./service.bend as S import ../frame.bend as Frame
Types
type Stdio source · line 9 · raw
Type
the process's stdin and stdout, and the bytes read but not yet framed
Stdio@inp:File -> @out:File -> @buf:List<&2, U32> -> Stdio
Definitions
def recv.grown source · line 13 · raw
@bytes:List<&2, U32> -> @inp:File -> @out:File -> @buf:List<&2, U32> -> @rest:(@_:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))) -> IO(Pair(Stdio, Maybe<&2, String>))
no bytes means the peer closed the pipe
def recv.fed source · line 26 · raw
@rr:Result<&1, &1, Pair(U32, String), List<&2, U32>> -> @inp:File -> @out:File -> @buf:List<&2, U32> -> @rest:(@_:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))) -> IO(Pair(Stdio, Maybe<&2, String>))
def recv.read source · line 39 · raw
@got:Pair(File, Result<&1, &1, Pair(U32, String), List<&2, U32>>) -> @out:File -> @buf:List<&2, U32> -> @rest:(@_:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))) -> IO(Pair(Stdio, Maybe<&2, String>))
def recv.on source · line 49 · raw
@cc:0x925a781ce1187774553f425315592b66/src/lsp/frame.Cut -> @inp:File -> @out:File -> @buf:List<&2, U32> -> @rest:(@_:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))) -> IO(Pair(Stdio, Maybe<&2, String>))
a whole message is cut off the buffer; short of one, read and look again
def recv.loop source · line 64 · raw
@fuel:Nat -> @h2:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))
def recv source · line 73 · raw
@h2:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))
the fuel bounds the reads one message may take
def send.done source · line 76 · raw
@ww:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @inp:File -> @buf:List<&2, U32> -> IO(Stdio)
def send source · line 81 · raw
@h2:Stdio -> @body:String -> IO(Stdio)
a body, framed and written
def open source · line 94 · raw
IO(Stdio)
the process's descriptors 0 and 1, wrapped
def new source · line 101 · raw
0x925a781ce1187774553f425315592b66/src/lsp/transport/service.Transport<Stdio>
the transport over stdio
Effects (foreign code)
effect stdio.fd source · line 89 · raw
@nn:U32 -> IO(File)
a File for a descriptor the process already holds. Not File.open on /dev/stdin: an editor may hand the server sockets, which no path opens
foreign: src/lsp/transport/fd.c, src/lsp/transport/fd.js