aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Registry.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-08-22 22:26:15 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 03:07:00 +0000
commit339c9b0e30719e2e68310c90a1c9ef27f54c9d09 (patch)
tree67de3040c0711c7f2a485bb7325521178898cb21 /lib/protocols/Registry.ml
parent300e4a04360d559618fa41fdf037a744e4e7c0eb (diff)
downloadRNT-339c9b0e30719e2e68310c90a1c9ef27f54c9d09.tar.gz
RNT-339c9b0e30719e2e68310c90a1c9ef27f54c9d09.zip
The registry protocol
Diffstat (limited to '')
-rw-r--r--lib/protocols/Registry.ml16
-rw-r--r--lib/protocols/Registry.mli13
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/protocols/Registry.ml b/lib/protocols/Registry.ml
new file mode 100644
index 0000000..4e3a44e
--- /dev/null
+++ b/lib/protocols/Registry.ml
@@ -0,0 +1,16 @@
+class type implementation = object
+ method register : string -> Handle.t -> (unit, Concepts.Condition.condition) result
+ method unregister : string -> (unit, Concepts.Condition.condition) result
+end
+
+type Handle.protocol += Registry of implementation
+
+type t = implementation
+
+let make impl = Registry impl
+
+let from handle = Handle.into handle (function Registry impl -> Some impl | _ -> None)
+
+let register i key value = Handle.invoke i (fun o -> o#register key value)
+
+let unregister i key = Handle.invoke i (fun o -> o#unregister key)
diff --git a/lib/protocols/Registry.mli b/lib/protocols/Registry.mli
new file mode 100644
index 0000000..855f8b8
--- /dev/null
+++ b/lib/protocols/Registry.mli
@@ -0,0 +1,13 @@
+type t
+
+class type implementation = object
+ method register : string -> Handle.t -> (unit, Concepts.Condition.condition) result
+ method unregister : string -> (unit, Concepts.Condition.condition) result
+end
+
+val make : implementation -> Handle.protocol
+
+val from : Handle.t -> t Handle.interface option
+
+val register : t Handle.interface -> string -> Handle.t -> (unit, Concepts.Condition.condition) result
+val unregister : t Handle.interface -> string -> (unit, Concepts.Condition.condition) result