My agentic slop goes here. Not intended for anyone else!
1(** Byte range management for partial downloads and chunked caching
2
3 This module provides utilities for working with byte ranges,
4 primarily used for HTTP Range requests and partial file caching.
5 Ranges are inclusive on both ends (e.g., bytes 0-99 includes 100 bytes).
6
7 {2 Example}
8
9 {[
10 let r1 = Range.create ~start:0L ~end_:999L in
11 let r2 = Range.create ~start:1000L ~end_:1999L in
12 assert (Range.adjacent r1 r2 = true);
13 assert (Range.length r1 = 1000L);
14 match Range.merge r1 r2 with
15 | Some merged -> assert (Range.length merged = 2000L)
16 | None -> failwith "Should merge"
17 ]}*)
18
19(** A byte range with inclusive start and end positions.
20 For example, range [0,99] includes bytes 0 through 99 (100 bytes total). *)
21type t
22
23(** Create a range from start to end (inclusive) *)
24val create : start:int64 -> end_:int64 -> t
25
26(** Get the start position *)
27val start : t -> int64
28
29(** Get the end position (inclusive) *)
30val end_ : t -> int64
31
32(** Calculate the length of a range *)
33val length : t -> int64
34
35(** Check if two ranges are adjacent (no gap between them) *)
36val adjacent : t -> t -> bool
37
38(** Check if two ranges overlap *)
39val overlaps : t -> t -> bool
40
41(** Check if a range contains a position *)
42val contains : t -> int64 -> bool
43
44(** Merge two ranges if they overlap or are adjacent *)
45val merge : t -> t -> t option
46
47(** Compare ranges by start position *)
48val compare : t -> t -> int
49
50(** Convert to string format "start-end" *)
51val to_string : t -> string
52
53(** Parse from string format "start-end" *)
54val of_string : string -> t option
55
56(** Pretty printer *)
57val pp : Format.formatter -> t -> unit