def encode.back

bend-kit-postgres@0.3.0.0 · codec.bend:210

import bend-kit-postgres@0.3.0.0/codec.bend as Codec
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

210# The wire bytes of a backend message, as a server sends it.
211def encode.back(m: Back) -> Bytes.Bytes:
212  match m:
213    case AuthOk{}:
214      auth.enc(0, Bytes.new(0))
215    case AuthCleartext{}:
216      auth.enc(3, Bytes.new(0))
217    case AuthSASL{ms}:
218      auth.enc(10, Bytes.concat(names.enc(ms)))
219    case AuthSASLContinue{d}:
220      auth.enc(11, d)
221    case AuthSASLFinal{d}:
222      auth.enc(12, d)
223    case AuthOther{+code, d}:
224      auth.enc(code, d)
225    case ParameterStatus{n, v}:
226      frame(83, Bytes.append(cstr.enc(n), cstr.enc(v)))
227    case BackendKeyData{+pid, +key}:
228      frame(75, Bytes.append(be32(pid), be32(key)))
229    case ReadyForQuery{+s}:
230      frame(90, byte1(s))
231    case RowDescription{fs}:
232      frame(84, n16(fields.enc(fs)))
233    case DataRow{cs}:
234      frame(68, n16(values(cs)))
235    case CommandComplete{t}:
236      frame(67, cstr.enc(t))
237    case ErrorResponse{fs}:
238      frame(69, Bytes.concat(notices.enc(fs)))
239    case NoticeResponse{fs}:
240      frame(78, Bytes.concat(notices.enc(fs)))
241    case ParseComplete{}:
242      frame(49, Bytes.new(0))
243    case BindComplete{}:
244      frame(50, Bytes.new(0))
245    case CloseComplete{}:
246      frame(51, Bytes.new(0))
247    case NoData{}:
248      frame(110, Bytes.new(0))
249    case EmptyQuery{}:
250      frame(73, Bytes.new(0))
251    case PortalSuspended{}:
252      frame(115, Bytes.new(0))
253    case Other{+tag, b}:
254      frame(tag, b)

Uses (15)

Used by (0)

No other definition uses this definition.