def read.loop
bend-kit-postgres@0.3.0.0 · postgres.bend:156
import bend-kit-postgres@0.3.0.0/postgres.bend as Postgres
import Base
import bend-kit-postgres@0.3.0.0/codec.bend as Codec
156
157def read.loop(fuel: Nat, st: Rd) -> IO(Result<&1, &1, Failure, Conn & Codec.Back>):
158 match fuel:
159 case 0n:
160 match st:
161 case RNext{tls, sock, key, ms, status, r}:
162 read.fail(tls, sock, Malformed{})
163 case RFail{tls, sock, why}:
164 read.fail(tls, sock, why)
165 case 1n+f:
166 match st:
167 case RFail{tls, sock, why}:
168 read.fail(tls, sock, why)
169 case RNext{+tls, sock, +key, +ms, +status, r}:
170 (rd, nx) = r
171 match nx:
172 case Codec.Got{Codec.NoticeResponse{fs}}:
173 read.loop(f, RNext{tls, sock, key, ms, status, Codec.next(rd)})
174 case Codec.Got{Codec.ParameterStatus{name, value}}:
175 read.loop(f, RNext{tls, sock, key, ms, status, Codec.next(rd)})
176 case Codec.Got{m}:
177 IO.pure(Result<&1, &1, Failure, Conn & Codec.Back>, Done{(Conn{tls, sock, rd, key, ms, status}, m)})
178 case Codec.Bad{}:
179 read.fail(tls, sock, Malformed{})
180 case Codec.Want{}:
181 do IO<Result<&1, &1, Failure, Conn & Codec.Back>>:
182 m : Socket & Result<&1, &1, U32 & String, U32 & Array<U32>> <- io.recv(tls, sock, ms)
183 read.loop(f, got(tls, key, ms, status, rd, m))