summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2015-09-28 20:51:58 +0600
committerDaniil Baturin <daniil@baturin.org>2015-09-28 20:51:58 +0600
commitf50401c6bdfb205f34de3d04949fbaf3cd6876f8 (patch)
tree366052a359ba710bfe4696a33f85eba8c4b166c5
parenta4f204cf23f56661af2577e070bba9d9ec678343 (diff)
downloadvyconf-f50401c6bdfb205f34de3d04949fbaf3cd6876f8.tar.gz
vyconf-f50401c6bdfb205f34de3d04949fbaf3cd6876f8.zip
Add types and derivers for the message decoder.
-rw-r--r--_oasis6
-rw-r--r--src/message.ml11
-rw-r--r--src/message.mli17
3 files changed, 34 insertions, 0 deletions
diff --git a/_oasis b/_oasis
index 2dcccd8..0c2b305 100644
--- a/_oasis
+++ b/_oasis
@@ -55,6 +55,12 @@ Library "vyconf_config"
FindlibParent: vyconf
BuildDepends: ppx_deriving_yojson
+Library "message"
+ Path: src
+ Modules: Message
+ FindlibParent: vyconf
+ BuildDepends: ppx_deriving_yojson
+
Executable "vyconfd"
Path: src
MainIs: vyconfd.ml
diff --git a/src/message.ml b/src/message.ml
new file mode 100644
index 0000000..8f37c08
--- /dev/null
+++ b/src/message.ml
@@ -0,0 +1,11 @@
+type operation = {
+ method_name: string;
+ path: string list option;
+ value: string option;
+ options: (string * string) list option
+} [@@deriving yojson]
+
+type message = {
+ session_id: string;
+ ops: operation list;
+} [@@deriving yojson]
diff --git a/src/message.mli b/src/message.mli
new file mode 100644
index 0000000..6de77b7
--- /dev/null
+++ b/src/message.mli
@@ -0,0 +1,17 @@
+type operation = {
+ method_name: string;
+ path: string list option;
+ value: string option;
+ options: (string * string) list option
+}
+
+type message = {
+ session_id: string;
+ ops: operation list;
+}
+
+val operation_to_yojson : operation -> Yojson.Safe.json
+val operation_of_yojson : Yojson.Safe.json -> [ `Error of bytes | `Ok of operation ]
+
+val message_to_yojson : message -> Yojson.Safe.json
+val message_of_yojson : Yojson.Safe.json -> [ `Error of bytes | `Ok of message ]