mte/src/util.ml

31 lines
688 B
OCaml
Raw Normal View History

2025-09-29 00:45:45 +02:00
module Protocol_version = struct
2025-10-17 15:09:47 +02:00
(* TODO *)
2025-09-29 00:45:45 +02:00
(* libtool version format *)
let current = 0
let revision = 0
let age = 0
let v = Fmt.str "%d:%d:%d"
end
2025-10-17 15:09:47 +02:00
(* -- Ptime -- *)
let ptime_to_int64_us p = Int64.of_float (1_000_000. *. Ptime.to_float_s p)
let ptime_of_span_exn span =
match Ptime.of_span span with
| None -> Fmt.failwith "Ptime.of_span: not in the range [min;max]"
| Some p -> p
let ptime_add_span_exn p span =
match Ptime.add_span p span with
| None -> Fmt.failwith "Ptime.add_span: not in the range [min;max]"
| Some v -> v
2025-10-17 15:25:10 +02:00
(* -- *** -- *)
(* TODO bin
- no [Bin.of_string] ? *)
let bin_of_string bin s =
let v = Bin.decode bin s (ref 0) in
Ok v