def encode.chunks
mylsm-lsm-store@0.6.0.1 · src/SstFile.bend:1771
import mylsm-lsm-store@0.6.0.1/src/SstFile.bend as SstFile
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes
1771
1772
1773def encode.chunks(
1774 fuel: Nat,
1775 pair: Encoder & Maybe<&1, Bytes.Bytes>,
1776 acc: List<&1, Bytes.Bytes>
1777) -> Result<&1, &1, Error, Bytes.Bytes>:
1778 match fuel:
1779 case 0n:
1780 Fail{TooLarge{}}
1781 case 1n+rest:
1782 match pair:
1783 case (_, None{}):
1784 Done{Bytes.concat(List.reverse(&1, Bytes.Bytes, acc))}
1785 case (encoder, Some{chunk}):
1786 encode.chunks(rest, next_chunk(encoder), Con{chunk, acc})