def read.sized

mylsm-lsm-store@0.6.0.1 · src/ByteManifestIo.bend:46

import mylsm-lsm-store@0.6.0.1/src/ByteManifestIo.bend as ByteManifestIo
import Base
import mylsm-lsm-store@0.6.0.1/src/ByteManifest.bend as Manifest
import mylsm-lsm-store@0.6.0.1/src/Fs.bend as Fs
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

46def read.sized(file: File, size: Nat) -> IO(Result<&1, &1, Error, Manifest.ManifestValue>):
47  match size:
48    case 56n:
49      do IO<Result<&1, &1, Error, Manifest.ManifestValue>>:
50        pair : File & Result<&1, &1, U32 & String, Bytes.Bytes> <- Fs.read_at(file, 0, 56)
51        read.decoded(pair)
52    case 63n:
53      do IO<Result<&1, &1, Error, Manifest.ManifestValue>>:
54        pair : File & Result<&1, &1, U32 & String, Bytes.Bytes> <- Fs.read_at(file, 0, 63)
55        read.decoded(pair)
56    case 60n:
57      do IO<Result<&1, &1, Error, Manifest.ManifestValue>>:
58        pair : File & Result<&1, &1, U32 & String, Bytes.Bytes> <- Fs.read_at(file, 0, 60)
59        read.decoded(pair)
60    case _:
61      do IO<Result<&1, &1, Error, Manifest.ManifestValue>>:
62        _closed : Unit <- File.close(file)
63        read.result(Fail{Manifest.Malformed{}})

Uses (17)

Used by (1)