BackupIo.loop: def of mylsm-lsm-store@0.6.0.1 Import: import mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend as BackupIo Lines 174-203 of mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend: https://jend.leeeet.dev/read.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&start_line=174&end_line=203 import Base import mylsm-lsm-store@0.6.0.1/src/transfer/Backup.bend as Backup import mylsm-lsm-store@0.6.0.1/src/Fs.bend as Fs # Writes one bounded encoded chunk per state transition before publication. def loop(fuel: Nat, +destination: String, +temporary: String, state: State) -> IO(Result<&1, &1, Error, Unit>): match fuel: case 0n: match state: case Need{file, _}: close.failed(file, temporary, (7, "backup stream exceeded its transition budget")) case Output{file, _}: close.failed(file, temporary, (7, "backup stream exceeded its transition budget")) case Written{(file, _), _}: do IO>: _closed : Unit <- File.close(file) cleanup(temporary) return Fail{Io{7, "backup stream exceeded its transition budget"}} case 1n+rest: match state: case Need{file, stream}: loop(rest, destination, temporary, Output{file, Backup.next(stream)}) case Output{file, result}: match result: case Fail{_}: close.failed(file, temporary, (22, "backup encoder rejected its snapshot")) case Done{Backup.End{}}: publish.closed(destination, temporary, file, Done{Unit{}}) case Done{Backup.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 Written{pair, stream}: match pair: case (file, Fail{error}): close.failed(file, temporary, error) case (file, Done{Unit{}}): loop(rest, destination, temporary, Need{file, stream}) Uses (20): 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=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/Backup.bend&name=Step https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/Backup.bend&name=next https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=Error https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=State https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=cleanup https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=close.failed https://jend.leeeet.dev/definition.txt?path=mylsm-lsm-store@0.6.0.1/src/transfer/BackupIo.bend&name=publish.closed