def next.body.valid
mylsm-lsm-store@0.6.0.1 · src/scan/ByteBlockReader.bend:1339
import mylsm-lsm-store@0.6.0.1/src/scan/ByteBlockReader.bend as ByteBlockReader
import Base
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
1339def next.body.valid(
1340 file: File,
1341 state: State,
1342 block_header: Bytes.Bytes,
1343 +used: Nat,
1344 +payload_length: U32,
1345 valid: Bool
1346) -> IO(Result<&1, &1, U32 & String, Step>):
1347 match valid:
1348 case False{}:
1349 close.failed(file, corruption("byte SST block exceeds file bounds"))
1350 case True{}:
1351 do IO<Result<&1, &1, U32 & String, Step>>:
1352 raw : File & Result<&1, &1, U32 & String, Bytes.Bytes> <-
1353 Fs.read_at(file,
1354 U32.from_nat(Nat.add(Nat.add(20n, used), 8n)),
1355 U32.add(payload_length, 32))
1356 next.body.result(BodyContext{state, block_header, payload_length},
1357 read_at.exact.pair(U32.add(payload_length, 32), raw))