bend-kit-cbor Releases (4): 0.3.0.0 0xce226e215fd8376197a24b17bdc4cb2b indexed https://jend.leeeet.dev/files.txt?path=bend-kit-cbor@0.3.0.0 0.2.0.0 0x50d253ff02f68be1c140402a881a0ac9 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-cbor@0.2.0.0 0.1.0.1 0x728e6e26db44a143290d5b9563297a19 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-cbor@0.1.0.1 0.1.0.0 0x6999cd3df5515b2fac39eb2342ea27c7 unindexed https://jend.leeeet.dev/files.txt?path=bend-kit-cbor@0.1.0.0 Definitions (96): Cbor.W64 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=W64) # Raw words preserve CBOR integer and floating-point bit patterns. type W64 is Data: W64{hi: U32, lo: U32} Cbor.Float (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Float) type Float is Data: Half{bits: U32} Single{bits: U32} Double{bits: W64} Cbor.Simple (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Simple) type Simple is Data: SFalse{} STrue{} SNull{} SUndefined{} Other{value: U32} Cbor.Val (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Val) type Val is Type: UInt{value: W64} NInt{value: W64} BStr{value: Bytes.Bytes} TStr{value: Bytes.Bytes} Arr{items: List<&1, Val>} Obj{items: List<&1, Val & Val>} Tag{number: W64, value: Val} Sim{value: Simple} Flt{value: Float} Cbor.W (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=W) type W is Type: W{buf: Array, cap: U32, n: U32, word: U32} Cbor.grow.if (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=grow.if) def grow.if(grow: Bool, buf: Array, +k: U32) -> Array: Cbor.put (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=put) def put(full: Bool, buf: Array, +cap: U32, +n: U32, +word: U32) -> W: Cbor.finish.buf (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=finish.buf) def finish.buf(full: Bool, cap: U32, buf: Array, +k: U32, +r: U32, +word: U32) -> Array: Cbor.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=byte) def byte(o: W, +b: U32) -> W: Cbor.finish (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=finish) def finish(o: W) -> Bytes.Bytes: Cbor.empty (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=empty) def empty() -> W: Cbor.head.small (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=head.small) def head.small(+major: U32, +v: U32, o: W) -> W: Cbor.head.u32.sixteen (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=head.u32.sixteen) def head.u32.sixteen(fits: Bool, +major: U32, +v: U32, o: W) -> W: Cbor.head.u32.eight (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=head.u32.eight) def head.u32.eight(fits: Bool, +major: U32, +v: U32, o: W) -> W: Cbor.head.u32.small (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=head.u32.small) def head.u32.small(small: Bool, +major: U32, +v: U32, o: W) -> W: Cbor.head.u32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=head.u32) def head.u32(+major: U32, +v: U32, o: W) -> W: Cbor.raw.u32 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=raw.u32) def raw.u32(o: W, +v: U32) -> W: Cbor.uint.bytes.small (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=uint.bytes.small) def uint.bytes.small(small: Bool, +major: U32, +hi: U32, +lo: U32, o: W) -> W: Cbor.uint.bytes (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=uint.bytes) def uint.bytes(+major: U32, v: W64, o: W) -> W: Cbor.raw.bytes.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=raw.bytes.go) def raw.bytes.go(n: Nat, r: Array & U32, +i: U32, o: W) -> W: Cbor.raw.bytes (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=raw.bytes) def raw.bytes(b: Bytes.Bytes, o: W) -> W: Cbor.Cp (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Cp) # RFC 3629 §4 validity, as in json: overlong forms, surrogates, and code points past U+10FFFF have width 0. type Cp is Data: Cp{c: U32, w: U32} Cbor.pk.if (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=pk.if) def pk.if(ok: Bool, a: Array, +i: U32) -> Array & U32: Cbor.pk (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=pk) # Byte i, or 256 at end, which no rule accepts. def pk(a: Array, +end: U32, +i: U32) -> Array & U32: Cbor.cont (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=cont) def cont(+b: U32) -> Bool: Cbor.utf8.n (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.n) def utf8.n(+b0: U32, +b1: U32, +b2: U32, +b3: U32) -> Cp: Cbor.utf8.b3 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.b3) def utf8.b3(+b0: U32, +b1: U32, +b2: U32, r: Array & U32) -> Array & Cp: Cbor.utf8.b2 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.b2) def utf8.b2(+end: U32, +i: U32, +b0: U32, +b1: U32, r: Array & U32) -> Array & Cp: Cbor.utf8.b1 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.b1) def utf8.b1(+end: U32, +i: U32, +b0: U32, r: Array & U32) -> Array & Cp: Cbor.utf8.cp (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.cp) def utf8.cp(+i: U32, r: Array & Cp) -> Array & U32 & Bool: Cbor.utf8.byte (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.byte) def utf8.byte(ascii: Bool, a: Array, +end: U32, +i: U32, +b: U32) -> Array & U32 & Bool: Cbor.utf8.lead (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.lead) def utf8.lead(+end: U32, +i: U32, r: Array & U32) -> Array & U32 & Bool: Cbor.utf8.more (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.more) def utf8.more(go: Bool, a: Array, +end: U32, +i: U32) -> Array & U32 & Bool: Cbor.utf8.step (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.step) def utf8.step(ok: Bool, a: Array, +end: U32, +i: U32) -> Array & U32 & Bool: Cbor.utf8.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.go) # Each step eats a whole code point, so end - i steps reach end. def utf8.go(n: Nat, r: Array & U32 & Bool, +end: U32) -> Array & Bool: Cbor.utf8.check (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=utf8.check) # Are bytes i until end well-formed UTF-8? def utf8.check(a: Array, +i: U32, +end: U32) -> Array & Bool: Cbor.text.fin (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=text.fin) def text.fin(+len: U32, r: Array & Bool) -> Bytes.Bytes & Bool: Cbor.text.check (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=text.check) def text.check(b: Bytes.Bytes) -> Bytes.Bytes & Bool: Cbor.simple.ok (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=simple.ok) # Simple values 20..23 have their own constructors, 24..31 are reserved (RFC 8949 §3.3). def simple.ok(+v: U32) -> Bool: Cbor.Item (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Item) # IGuard aborts the encoding when a value has no CBOR form; IText carries a text string and its UTF-8 check. type Item is Type: IVal{value: Val} IArr{items: List<&1, Val>} IMap{items: List<&1, Val & Val>} IArrLen{value: List<&1, Val> & Nat} IMapLen{value: List<&1, Val & Val> & Nat} IGuard{ok: Bool} IText{value: Bytes.Bytes & Bool} Cbor.vals.length.put (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=vals.length.put) def vals.length.put(h: Val, r: List<&1, Val> & Nat) -> List<&1, Val> & Nat: Cbor.pairs.length.put (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=pairs.length.put) def pairs.length.put(h: Val & Val, r: List<&1, Val & Val> & Nat) -> List<&1, Val & Val> & Nat: Cbor.vals.length (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=vals.length) def vals.length(xs: List<&1, Val>) -> List<&1, Val> & Nat: Cbor.pairs.length (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=pairs.length) def pairs.length(xs: List<&1, Val & Val>) -> List<&1, Val & Val> & Nat: Cbor.size.arr (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size.arr) def size.arr(h: Val, r: Val & Nat) -> Val & Nat: Cbor.size.obj (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size.obj) def size.obj(k: Val, v: Val, r: Val & Nat) -> Val & Nat: Cbor.size.cons (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size.cons) def size.cons(hr: Val & Nat, r: Val & Nat) -> Val & Nat: Cbor.size.pair (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size.pair) def size.pair(kr: Val & Nat, vr: Val & Nat, r: Val & Nat) -> Val & Nat: Cbor.size.tag (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size.tag) def size.tag(+number: W64, r: Val & Nat) -> Val & Nat: Cbor.size (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=size) # v, and at least the number of encode.go steps it takes. def size(v: Val) -> Val & Nat: Cbor.encode.go (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=encode.go) # fuel bounds the steps; size(v) gives enough, so the 0n arm is never reached. def encode.go(fuel: Nat, items: List<&1, Item>, o: W) -> Maybe<&1, W>: Cbor.encode.done (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=encode.done) def encode.done(r: Maybe<&1, W>) -> Maybe<&1, Bytes.Bytes>: Cbor.encode.sized (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=encode.sized) def encode.sized(r: Val & Nat) -> Maybe<&1, Bytes.Bytes>: Cbor.encode (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=encode) # Definite lengths and the shortest head for every length, integer, and tag; floats keep their width. # None when a TStr is not UTF-8, a Half has more than 16 bits, or Other is not a simple value 0..19 or 32..255. def encode(v: Val) -> Maybe<&1, Bytes.Bytes>: Cbor.decode.other (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=decode.other) def decode.other(ok: Bool, +value: U32) -> Maybe<&1, Val>: Cbor.decode.simple (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=decode.simple) def decode.simple(+ai: U32) -> Maybe<&1, Val>: Cbor.decode.major7.arg (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=decode.major7.arg) def decode.major7.arg(+ai: U32, +arg: W64) -> Maybe<&1, Val>: Cbor.decode.major7 (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=decode.major7) def decode.major7(small: Bool, +ai: U32, +arg: W64) -> Maybe<&1, Val>: Cbor.Hd (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Hd) # A head: major type, additional info, argument, and the index after it. type Hd is Data: Hd{major: U32, ai: U32, arg: W64, next: U32} Cbor.hd.words (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=hd.words) # n argument bytes from j, most significant first. def hd.words(n: Nat, r: Array & U32, +j: U32, +hi: U32, +lo: U32, +major: U32, +ai: U32) -> Array & Maybe<&2, Hd>: Cbor.hd.wide (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=hd.wide) def hd.wide(ok: Bool, n: Nat, a: Array, +i: U32, +major: U32, +ai: U32) -> Array & Maybe<&2, Hd>: Cbor.hd.arg (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=hd.arg) # ai 24..27 take 1, 2, 4 or 8 more bytes; 28..30 are reserved; 31 is indefinite or break. def hd.arg(+ai: U32, a: Array, +len: U32, +i: U32, +major: U32) -> Array & Maybe<&2, Hd>: Cbor.hd.of (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=hd.of) def hd.of(+len: U32, +i: U32, r: Array & U32) -> Array & Maybe<&2, Hd>: Cbor.hd.read (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=hd.read) def hd.read(ok: Bool, a: Array, +len: U32, +i: U32) -> Array & Maybe<&2, Hd>: Cbor.bstr.some (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=bstr.some) def bstr.some(+n: U32, r: Array & Array) -> Array & Maybe<&1, Bytes.Bytes>: Cbor.bstr.copy (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=bstr.copy) def bstr.copy(+n: U32, +i: U32, r: Array & Bool) -> Array & Maybe<&1, Bytes.Bytes>: Cbor.bstr.valid (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=bstr.valid) def bstr.valid(text: Bool, a: Array, +i: U32, +end: U32) -> Array & Bool: Cbor.bstr.fit (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=bstr.fit) def bstr.fit(ok: Bool, +text: Bool, a: Array, +n: U32, +i: U32) -> Array & Maybe<&1, Bytes.Bytes>: Cbor.bstr.read (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=bstr.read) # A definite string of arg bytes from i. None when it runs past len, or when text is not UTF-8. def bstr.read(+text: Bool, +arg: W64, a: Array, +len: U32, +i: U32) -> Array & Maybe<&1, Bytes.Bytes>: Cbor.wrap (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=wrap) def wrap(text: Bool, b: Bytes.Bytes) -> Val: Cbor.Frame (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=Frame) # An open container. Items are reversed; left counts the definite items (or pairs) still due, this one included. type Frame is Type: FArr{left: U32, xs: List<&1, Val>} FArrI{xs: List<&1, Val>} FMap{left: U32, kvs: List<&1, Val & Val>} FKey{left: U32, kvs: List<&1, Val & Val>, key: Val} FMapI{kvs: List<&1, Val & Val>} FKeyI{kvs: List<&1, Val & Val>, key: Val} FTag{number: W64} Cbor.St (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=St) # SHead reads an item at i; SChunk reads the next chunk of an indefinite string; SDone hands v to the open frame. type St is Type: SHead{i: U32, stack: List<&1, Frame>} SChunk{i: U32, text: Bool, chunks: List<&1, Bytes.Bytes>, stack: List<&1, Frame>} SDone{v: Val, i: U32, stack: List<&1, Frame>} SOk{v: Val} SFail{} Cbor.item.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.str) def item.str(+text: Bool, +i: U32, stack: List<&1, Frame>, r: Array & Maybe<&1, Bytes.Bytes>) -> Array & St: Cbor.item.empty (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.empty) def item.empty(map: Bool, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.push (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.push) def item.push(map: Bool, +n: U32, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.open (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.open) def item.open(empty: Bool, +map: Bool, +n: U32, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.count (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.count) def item.count(ok: Bool, +map: Bool, +n: U32, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.len (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.len) # Every item takes a byte, so a count past the bytes left is malformed; this also keeps it in a U32. def item.len(+map: Bool, +arg: W64, +len: U32, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.simple (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.simple) def item.simple(m: Maybe<&1, Val>, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.def (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.def) def item.def(+major: U32, +ai: U32, +arg: W64, +i: U32, a: Array, +len: U32, stack: List<&1, Frame>) -> Array & St: Cbor.brk.fr (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=brk.fr) # A break closes the innermost indefinite array, or map with no key pending; anywhere else it is malformed. def brk.fr(fr: Frame, +i: U32, rest: List<&1, Frame>) -> St: Cbor.brk (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=brk) def brk(stack: List<&1, Frame>, +i: U32) -> St: Cbor.item.indef (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.indef) # ai 31: indefinite string, array, or map, or (major 7) a break. Majors 0, 1 and 6 have no indefinite form. def item.indef(+major: U32, +i: U32, stack: List<&1, Frame>) -> St: Cbor.item.hd (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=item.hd) def item.hd(indef: Bool, +major: U32, +ai: U32, +arg: W64, +i: U32, a: Array, +len: U32, stack: List<&1, Frame>) -> Array & St: Cbor.step.head (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=step.head) def step.head(stack: List<&1, Frame>, +len: U32, r: Array & Maybe<&2, Hd>) -> Array & St: Cbor.chunk.str (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=chunk.str) def chunk.str(+text: Bool, chunks: List<&1, Bytes.Bytes>, +i: U32, stack: List<&1, Frame>, r: Array & Maybe<&1, Bytes.Bytes>) -> Array & St: Cbor.chunk.more (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=chunk.more) def chunk.more(ok: Bool, +text: Bool, chunks: List<&1, Bytes.Bytes>, +arg: W64, +i: U32, a: Array, +len: U32, stack: List<&1, Frame>) -> Array & St: Cbor.chunk.end (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=chunk.end) # Each chunk is a definite string of the same major type, UTF-8 by itself for text (RFC 8949 §3.2.3). def chunk.end(stop: Bool, ok: Bool, +text: Bool, chunks: List<&1, Bytes.Bytes>, +arg: W64, +i: U32, a: Array, +len: U32, stack: List<&1, Frame>) -> Array & St: Cbor.step.chunk (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=step.chunk) def step.chunk(+text: Bool, chunks: List<&1, Bytes.Bytes>, stack: List<&1, Frame>, +len: U32, r: Array & Maybe<&2, Hd>) -> Array & St: Cbor.done.arr (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=done.arr) def done.arr(last: Bool, +left: U32, xs: List<&1, Val>, +i: U32, rest: List<&1, Frame>) -> St: Cbor.done.map (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=done.map) def done.map(last: Bool, +left: U32, kvs: List<&1, Val & Val>, +i: U32, rest: List<&1, Frame>) -> St: Cbor.done.fr (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=done.fr) def done.fr(fr: Frame, v: Val, +i: U32, rest: List<&1, Frame>) -> St: Cbor.done.top (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=done.top) def done.top(end: Bool, v: Val) -> St: Cbor.done (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=done) # A finished top-level item must end the input. def done(stack: List<&1, Frame>, v: Val, +i: U32, +len: U32) -> St: Cbor.run (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=run) def run(fuel: Nat, r: Array & St, +len: U32) -> Maybe<&1, Val>: Cbor.decode (https://jend.leeeet.dev/definition.txt?path=bend-kit-cbor@0.3.0.0/cbor.bend&name=decode) # One well-formed data item (RFC 8949 §3, Appendix C) filling b. Indefinite strings, arrays and maps come back # definite, with chunks joined. None for truncation, reserved ai 28..30, a misplaced break or indefinite form, # a simple value 0..31 in two bytes, text that is not UTF-8, or trailing bytes. # fuel: a head or chunk eats a byte, and each SDone step follows one, so 2 * len + 2 steps are enough. def decode(b: Bytes.Bytes) -> Maybe<&1, Val>: