summaryrefslogtreecommitdiff
path: root/lib/schema.ml
blob: 40b058aee12fbeaf88ce2f7c1985719de77199b8 (plain)
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
(*─────────────────────────────────────────────────────────────────────────────┐
│ SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/>             │
│ SPDX-License-Identifier: LGPL-2.1-or-later WITH OCaml-LGPL-linking-exception │
└─────────────────────────────────────────────────────────────────────────────*)
module Version = struct
	type t =
		| V0_1_1
		| V0_2_0
	[@@deriving show, enum, eq, ord]

	let of_string s =
		match s with
		| "0.1.1" -> Some V0_1_1
		| "0.2.0" -> Some V0_2_0
		| _ -> None

	let to_string = function
		| V0_1_1 -> "0.1.1"
		| V0_2_0 -> "0.2.0"

	let current : t = Option.get (of_enum max)

	let versions : t array =
		let vs = Dynarray.create () in
		for idx = min to max do
			match of_enum idx with
			| Some v -> Dynarray.add_last vs v
			| None -> ()
		done;
		Dynarray.to_array vs
end