def digest.read.go
mylsm-lsm-store@0.6.0.1 · src/Wal.bend:331
import mylsm-lsm-store@0.6.0.1/src/Wal.bend as Wal
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
331def digest.read.go(
332 remaining: Nat,
333 input: DigestRead,
334 digest: Bytes.Bytes,
335 +offset: U32
336) -> Bytes.Cursor & Result<&1, &1, Error, Bytes.Bytes>:
337 match remaining input:
338 case 0n DigestInput{cursor, _}:
339 (cursor, Done{digest})
340 case 1n+0n DigestInput{cursor, Some{word}}:
341 (cursor, Done{Bytes.set.u32be(digest, offset, word)})
342 case 1n+1n+rest DigestInput{cursor, Some{word}}:
343 digest.read.go(1n+rest, digest.read.wrap(Bytes.Cursor.u32be(cursor)),
344 Bytes.set.u32be(digest, offset, word), (offset + 4 : U32))
345 case 1n+_ DigestInput{cursor, None{}}:
346 (cursor, Fail{Malformed{}})