mte/src/bbin.ml

11 lines
338 B
OCaml

let encode bin t =
try Ok (Bin.to_string bin t)
with Invalid_argument e ->
Fmt.error "Bin encode error %s" e
|> Result.map_error (fun e -> `Bin_encode e)
let decode bin o =
try Ok (Bin.decode bin o (ref 0))
with Invalid_argument e ->
Fmt.error "Bin decode error %s" e
|> Result.map_error (fun e -> `Bin_decode e)