diff options
| author | Matias Goldfeld <[email protected]> | 2021-01-29 13:40:29 -0500 |
|---|---|---|
| committer | Matias Goldfeld <[email protected]> | 2021-01-29 13:40:29 -0500 |
| commit | 7ad203a0249bd9db50dfb1df4adb9b7483406e30 (patch) | |
| tree | 52696cb3e1c16a84513fb90fe50c3738ce4539cb /lib/models/id/user_id_t.ml | |
| parent | Started conversion to ppx_yojson_conv (diff) | |
| download | disml-7ad203a0249bd9db50dfb1df4adb9b7483406e30.tar.xz disml-7ad203a0249bd9db50dfb1df4adb9b7483406e30.zip | |
Revert "Started conversion to ppx_yojson_conv"
This reverts commit c937240fdd2036edd493debb76117165e4084e8b.
Diffstat (limited to 'lib/models/id/user_id_t.ml')
| -rw-r--r-- | lib/models/id/user_id_t.ml | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/models/id/user_id_t.ml b/lib/models/id/user_id_t.ml index fab0f00..214fa14 100644 --- a/lib/models/id/user_id_t.ml +++ b/lib/models/id/user_id_t.ml @@ -1,7 +1,15 @@ open Core
-type t = Snowflake.t [@@deriving sexp, yojson]
+type t = [ `User_id of Snowflake.t ] [@@deriving sexp]
-let compare t t' = Int64.compare t t'
+let compare (`User_id t) (`User_id t') = Int64.compare t t'
-let get_id id = id
\ No newline at end of file +let of_yojson a : (t, string) result =
+ match Snowflake.of_yojson a with
+ | Ok id -> Ok (`User_id id)
+ | Error err -> Error err
+
+let of_yojson_exn a : t = `User_id (Snowflake.of_yojson_exn a)
+let to_yojson (`User_id id) = (Snowflake.to_yojson id)
+
+let get_id (`User_id id) = id
\ No newline at end of file |