def hd.arg

bend-kit-cbor@0.3.0.0 · cbor.bend:472

import bend-kit-cbor@0.3.0.0/cbor.bend as Cbor
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes

472# ai 24..27 take 1, 2, 4 or 8 more bytes; 28..30 are reserved; 31 is indefinite or break.
473def hd.arg(+ai: U32, a: Array<U32>, +len: U32, +i: U32, +major: U32) -> Array<U32> & Maybe<&2, Hd>:
474  match ai:
475    case 24:
476      hd.wide(Bytes.fits(len, (i + 1 : U32), 1), 1n, a, i, major, 24)
477    case 25:
478      hd.wide(Bytes.fits(len, (i + 1 : U32), 2), 2n, a, i, major, 25)
479    case 26:
480      hd.wide(Bytes.fits(len, (i + 1 : U32), 4), 4n, a, i, major, 26)
481    case 27:
482      hd.wide(Bytes.fits(len, (i + 1 : U32), 8), 8n, a, i, major, 27)
483    case 28:
484      (a, None{})
485    case 29:
486      (a, None{})
487    case 30:
488      (a, None{})
489    case _:
490      (a, Some{Hd{major, ai, W64{0, ai}, (i + 1 : U32)}})

Uses (13)

Used by (1)