def recv.on

bolt@1.27.0.0 · src/lsp/transport/stdio.bend:52

import bolt@1.27.0.0/src/lsp/transport/stdio.bend as Stdio
import Base
import bolt@1.27.0.0/src/lsp/frame.bend as Frame

52# a whole message is cut off the buffer; short of one, read and look again
53def recv.on(
54  cc: Frame.Cut,
55  inp: File,
56  out: File,
57  buf: List<&2, U32>,
58  rest: Stdio -> IO(Stdio & Maybe<&2, String>)
59) -> IO(Stdio & Maybe<&2, String>):
60  match cc:
61    case Frame.Whole{body, left}:
62      IO.pure(Stdio & Maybe<&2, String>, (Stdio{inp, out, left}, Some{Frame.decode(body)}))
63    case Frame.More{}:
64      do IO<Stdio & Maybe<&2, String>>:
65        got : File & Result<&1, &1, U32 & String, List<&2, U32>> <- File.read_bytes(inp, 65536)
66        recv.read(got, out, buf, rest)

Uses (16)

Used by (1)