def read.repeated

bendonnect-rpc@0.1.0.0 · src/pbjson.bend:632

import bendonnect-rpc@0.1.0.0/src/pbjson.bend as Pbjson
import Base
import bend-kit-json@0.6.1.1/json.bend as Json

632# null -> []; array -> each element through read (for messages pass ~Msg.from_json).
633def read.repeated(~T: Data, ~read: Json.Val -> Result<&2, &1, String, T>, v: Json.Val) -> Result<&2, &1, String, List<&2, T>>:
634  match v:
635    case Json.Null{}:
636      Done{Nil{}}
637    case Json.Arr{xs}:
638      rep.read(~T, ~read, xs)
639    case Json.Flag{on}:
640      Fail{"expected an array"}
641    case Json.Num{s}:
642      Fail{"expected an array"}
643    case Json.Str{s}:
644      Fail{"expected an array"}
645    case Json.Obj{kvs}:
646      Fail{"expected an array"}

Uses (5)

Used by (16)