package guardian

  1. Overview
  2. Docs

Source file uuid.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
module type Sig = Sig.Uuid

module UuidBase = struct
  include Uuidm

  let to_yojson t = `String (to_string t)

  let of_yojson = function
    | `String s ->
      of_string s |> CCOption.to_result (Format.asprintf "Invalid UUID: %s" s)
    | _ -> CCResult.Error "Invalid argument"
  ;;

  let of_string_exn s =
    of_string s
    |> CCOption.get_exn_or (Format.asprintf "'%10s' is not a valid uuid" s)
  ;;

  let create () = v `V4
end

module Actor = struct
  include UuidBase
end

module Target = struct
  include UuidBase
end