package decoders-cbor
CBOR backend for decoders
Install
Dune Dependency
Authors
Maintainers
Sources
decoders-v0.6.0.tbz
sha256=e7e3d43685e01aabf8c285c228a3bee9d601feff4fa065fe177860f16f3bed9e
sha512=d9774df8145367eb078016c9cdd3a80208b7c92ce6412e8bbb1c3b0fab370cac9a105014c996c7eeb2c32997fa9e4f94884ea897a435ba0785eff20e135b67bd
doc/src/decoders-cbor/decode.ml.html
Source file decode.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
open Decoders module Cbor_decodeable : Decode.Decodeable with type value = CBOR.Simple.t = struct type value = CBOR.Simple.t let pp fmt t = Format.fprintf fmt "@[%s@]" (CBOR.Simple.to_diagnostic t) let of_string (input : string) : (value, string) result = try Ok (CBOR.Simple.decode input) with CBOR.Error msg -> Error msg let of_file (file : string) : (value, string) result = try Ok (Decoders_util.with_file_in file (fun chan -> Decoders_util.read_all chan |> CBOR.Simple.decode)) with | e -> Error (Printexc.to_string e) let get_string = function `Text str -> Some str | _ -> None let get_int = function `Int int -> Some int | _ -> None let get_float = function `Float float -> Some float | _ -> None let get_null = function `Null -> Some () | _ -> None let get_bool = function `Bool bool -> Some bool | _ -> None let get_list = function `Array a -> Some a | _ -> None let get_key_value_pairs = function `Map assoc -> Some assoc | _ -> None let to_list vs = `Array vs end include Decode.Make (Cbor_decodeable) (* CBOR-specific decoders *) let undefined : unit decoder = { run = (function | `Undefined -> Ok () | json -> (fail "Expected Undefined").run json) } let simple : int decoder = { run = (function `Simple i -> Ok i | json -> (fail "Expected Simple").run json) } let bytes : string decoder = { run = (function `Bytes b -> Ok b | json -> (fail "Expected bytes").run json) }
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>