def stdio.got

ezmcp@0.1.0.0 · src/io.bend:353

import ezmcp@0.1.0.0/src/io.bend as Io
import Base
import emerging-ezjson@1.2.0.0/src/value.bend as Value
import ezmcp@0.1.0.0/src/rpc.bend as Rpc
import ezmcp@0.1.0.0/src/server.bend as Server

353# after one read: a failure is logged to stderr and ends the loop
354def stdio.got(
355  ~C: Data,
356  ~run: C -> String -> Value.Json -> IO(Rpc.Out),
357  ~srv: Server.Server,
358  +ctx: C,
359  rev: String,
360  buf: List<&2, U32>,
361  again: List<&2, U32> -> String -> IO(Unit),
362  res: Result<&1, &1, U32 & String, List<&2, U32>>
363) -> IO(Unit):
364  match res:
365    case Fail{(_code, why)}:
366      IO.print_err("ezmcp: stdin: " ++ why)
367    case Done{+bytes}:
368      stdio.chunked(C, run, srv, ctx, rev, buf, bytes, again,
369        List.is_empty(&2, U32, bytes))

Uses (15)

Used by (1)