SstStreamIo.read.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend as SstStreamIo Lines 326-368 of mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&start_line=326&end_line=368 import Base import mylsm-lsm-store@0.6.0.1/src/Sstable.bend as Sstable import mylsm-lsm-store@0.6.0.1/src/SstFile.bend as SstFile def read.loop(fuel: Nat, state: StreamReadState) -> IO(Result<&1, &1, U32 & String, Sstable.Table>): match fuel: case 0n: read.exhausted(state) case 1n+rest: match state: case ReadHeader{file, size}: do IO>: pair : File & Result<&1, &1, U32 & String, ExactResult> <- exact.start(file, 20n) read.loop(rest, read.header.state(read.exact.state(pair), size)) case ReadHeaderResult{pair, size}: read.loop(rest, read.header.state(pair, size)) case ReadBlocks{file, size, used, parser}: match parser: case SstFile.StreamState{_, _, _, 0, _, _, _, _}: do IO>: pair : File & Result<&1, &1, U32 & String, ExactResult> <- exact.start(file, 40n) read.loop(rest, read.footer.state(read.exact.state(pair), size, used, parser)) case SstFile.StreamState{+level, +total, +block_count, +remaining, +entries_left, +previous, entries, hashes}: do IO>: pair : File & Result<&1, &1, U32 & String, ExactResult> <- exact.start(file, 8n) read.loop(rest, read.block.header.state(read.exact.state(pair), size, used, SstFile.StreamState{level, total, block_count, remaining, entries_left, previous, entries, hashes})) case ReadBlockHeaderResult{pair, size, used, parser}: read.loop(rest, read.block.header.state(pair, size, used, parser)) case ReadBlockBody{file, size, used, parser, header, +tail_len}: do IO>: pair : File & Result<&1, &1, U32 & String, ExactResult> <- exact.start(file, U32.to_nat(tail_len)) read.loop(rest, ReadBlockBodyResult{read.exact.state(pair), size, used, parser, header, tail_len}) case ReadBlockBodyResult{pair, size, used, parser, header, tail_len}: read.loop(rest, read.block.body.state(pair, size, used, parser, header, tail_len)) case ReadFooterResult{pair, size, used, parser}: read.loop(rest, read.footer.state(pair, size, used, parser)) case ReadClose{file, result}: do IO>: _closed : Unit <- File.close(file) return result Uses (26): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File.close https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.bind https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=IO.pure https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Pair https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Result https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.to_nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Unit https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Con https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Word.Nil https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstFile.bend&name=StreamState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=ExactResult https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=StreamReadState https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=exact.start https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.block.body.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.block.header.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.exact.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.exhausted https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.footer.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/SstStreamIo.bend&name=read.header.state https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/Sstable.bend&name=Table