def packed.tail

mylsm-lsm-store@0.6.0.1 · src/hub_sha/sha256.bend:122

import mylsm-lsm-store@0.6.0.1/src/hub_sha/sha256.bend as Sha256
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Packed

122# Read the remaining fewer than 64 bytes for the existing constant-space tail
123# padding routines. This list is bounded by 63 octets, regardless of file size.
124def packed.tail(
125  remaining: Nat,
126  pair: Packed.Cursor & Maybe<&2, U32>,
127  acc: List<&2, U32>
128) -> Packed.Cursor & List<&2, U32>:
129  match remaining:
130    case 0n:
131      match pair:
132        case (cursor, _):
133          (cursor, List.reverse(&2, U32, acc))
134    case 1n:
135      match pair:
136        case (cursor, Some{byte}):
137          (cursor, List.reverse(&2, U32, byte <> acc))
138        case (cursor, None{}):
139          (cursor, Nil{})
140    case 1n+more:
141      match pair:
142        case (cursor, Some{byte}):
143          packed.tail(more, Packed.Cursor.u8(cursor), byte <> acc)
144        case (cursor, None{}):
145          (cursor, Nil{})

Uses (9)

Used by (1)