BackupCursorIo.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend as BackupCursorIo Lines 218-250 of mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&start_line=218&end_line=250 import Base import mylsm-lsm-store@0.6.0.1/src/Fs.bend as Fs import mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursor.bend as BackupCursor import mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend as BackupIo # Pulls at most one visible cursor result and writes at most one encoded chunk. def loop( fuel: Nat, +destination: String, +temporary: String, state: State ) -> IO(Result<&1, &1, BackupIo.Error, Unit>): match fuel: case 0n: loop.abort(temporary, state) case 1n+rest: match state: case Need{file, stream}: do IO>: step : BackupCursor.Step <- source.step(stream) loop(rest, destination, temporary, Output{file, step}) case Output{file, step}: match step: case BackupCursor.Failure{cursor, error}: close.error(file, temporary, cursor, error) case BackupCursor.Continue{stream}: loop(rest, destination, temporary, Need{file, stream}) case BackupCursor.Chunk{stream, bytes}: do IO>: written : File & Result<&1, &1, U32 & String, Unit> <- Fs.write_bytes(file, bytes) loop(rest, destination, temporary, Written{written, stream}) case BackupCursor.End{}: close.file(destination, temporary, file) case Written{pair, stream}: match pair: case (file, Fail{error}): close.stream(file, temporary, stream, error) case (file, Done{Unit{}}): loop(rest, destination, temporary, Need{file, stream}) Uses (19): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=File 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=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=Sigma 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=Unit https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/Fs.bend&name=write_bytes https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursor.bend&name=Step https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=State https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=close.error https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=close.file https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=close.stream https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=loop.abort https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupCursorIo.bend&name=source.step https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=Error