def decode.step.kind
bend-kit-protobuf@0.2.0.0 · protobuf.bend:224
import bend-kit-protobuf@0.2.0.0/protobuf.bend as Protobuf
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as B
224def decode.step.kind(kind: U32, c: B.Cursor, +depth: Nat, stack: List<&1, Frame>, acc: List<&1, Field>, +number: U32) -> Result<&2, &1, Error, DecodeState>:
225 match kind:
226 case 3:
227 match depth:
228 case 0n:
229 Fail{Limit{}}
230 case 1n+d:
231 Done{decode.state(c, d, Con{Frame{number, acc, 1n+d}, stack}, Nil{})}
232 case 4:
233 match stack:
234 case Nil{}:
235 Fail{Malformed{}}
236 case Con{Frame{expected, outer, parent_depth}, tail}:
237 decode.step.close(U32.is_eq(number, expected), c, number, outer, parent_depth, tail, acc)
238 case _:
239 do Result<&2, &1, Error, DecodeState>:
240 r : B.Cursor & Value <- read_value(kind, c)
241 decode.step.value(depth, stack, acc, number, r)