src/lsp/transport/stdio.bend relies on unsafe/foreign
raw source on the hub · import bolt@1.27.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.
Trusted, not proved: the transport effect (fd.c, fd.js) delivers stdin bytes in order and writes stdout bytes whole; it is foreign code over descriptors 0 and 1.
3 imports
import Base import ./service.bend as S import ../frame.bend as Frame
Types
type Stdio source · line 13 · 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 17 · 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 30 · 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 43 · 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 53 · raw
@cc:0xe80b84e038766a5c0c16cf84a1d6b0cf/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 68 · raw
@fuel:Nat -> @h2:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))
def recv source · line 77 · raw
@h2:Stdio -> IO(Pair(Stdio, Maybe<&2, String>))
the fuel bounds the reads one message may take
def send.done source · line 80 · raw
@ww:Pair(File, Result<&1, &1, Pair(U32, String), Unit>) -> @inp:File -> @buf:List<&2, U32> -> IO(Stdio)
def send source · line 85 · raw
@h2:Stdio -> @body:String -> IO(Stdio)
a body, framed and written
def open source · line 98 · raw
IO(Stdio)
the process's descriptors 0 and 1, wrapped
def new source · line 105 · raw
0xe80b84e038766a5c0c16cf84a1d6b0cf/src/lsp/transport/service.Transport<Stdio>
the transport over stdio
Effects (foreign code)
effect stdio.fd source · line 93 · 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