LegacyWal.replay.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend as LegacyWal Lines 333-370 of mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&start_line=333&end_line=370 import Base import mylsm-lsm-store@0.6.0.1/src/Wal.bend as Wal import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes def replay.loop(fuel: Nat, state: ReplayState) -> ReplayResult: match fuel: case 0n: ReplayInvalid{} case 1n+rest: match state: case ReplayNeed{bytes, offset, batches}: replay.loop(rest, replay.measure(Bytes.length(bytes), offset, batches)) case ReplayMeasured{bytes, offset, batches, size}: +total = U32.to_nat(size) replay.loop(rest, replay.bound.state(bytes, offset, batches, total)) case ReplayBound{bytes, offset, batches, total, at_end, has_length}: match at_end: case True{}: ReplayValid{batches} case False{}: match has_length: case True{}: replay.loop(rest, replay.length.state(bytes, offset, total, batches)) case False{}: ReplayInvalid{} case ReplayLength{bytes, next_offset, total, batches, length}: match length: case None{}: ReplayInvalid{} case Some{frame_length}: replay.loop(rest, replay.frame.state(bytes, next_offset, total, batches, frame_length)) case ReplayFrame{bytes, next_offset, frame_end, batches, length, fits}: match fits: case True{}: replay.loop(rest, replay.frame.decoded(Bytes.slice(bytes, U32.from_nat(next_offset), length), frame_end, batches)) case False{}: ReplayInvalid{} case ReplayDecoded{bytes, next_offset, batches, result}: match result: case Fail{_}: ReplayInvalid{} case Done{batch}: replay.loop(rest, ReplayNeed{bytes, next_offset, List.append(&2, Wal.Batch, batches, Con{batch, Nil{}})}) Uses (18): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=List.append https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Maybe https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.from_nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=length https://jend.leeeet.dev/definition.txt?path=bend-kit-bytes@0.3.3.0/bytes.bend&name=slice https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/Wal.bend&name=Batch https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=ReplayResult https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=ReplayState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=replay.bound.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=replay.frame.decoded https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=replay.frame.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=replay.length.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/LegacyWal.bend&name=replay.measure