def parse.hash.words.go
mylsm-lsm-store@0.6.0.1 · src/SstFile.bend:896
import mylsm-lsm-store@0.6.0.1/src/SstFile.bend as SstFile
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
896
897def parse.hash.words.go(
898 remaining: Nat,
899 read: HashRead,
900 digest: Bytes.Bytes,
901 +offset: U32
902) -> Bytes.Cursor & Result<&1, &1, Error, Bytes.Bytes>:
903 match remaining read:
904 case 0n HashInput{cursor, _}:
905 (cursor, Done{digest})
906 case 1n+0n HashInput{cursor, Some{word}}:
907 (cursor, Done{Bytes.set.u32be(digest, offset, word)})
908 case 1n+1n+rest HashInput{cursor, Some{word}}:
909 parse.hash.words.go(1n+rest, parse.hash.wrap(Bytes.Cursor.u32be(cursor)),
910 Bytes.set.u32be(digest, offset, word), (offset + 4 : U32))
911 case 1n+_ HashInput{cursor, None{}}:
912 (cursor, Fail{Malformed{}})