aboutsummaryrefslogtreecommitdiffstats
path: root/lib/protocols/Directory.ml
diff options
context:
space:
mode:
authorEstevan Castilho <tevo@riajuu.net>2026-08-22 22:16:47 +0000
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 03:07:00 +0000
commit300e4a04360d559618fa41fdf037a744e4e7c0eb (patch)
tree17775422f756ca4145099aad79dc6a5a682b37ae /lib/protocols/Directory.ml
parent44851daf1601f0f7ac1ff22bc5677c07dfd4ae2e (diff)
downloadRNT-300e4a04360d559618fa41fdf037a744e4e7c0eb.tar.gz
RNT-300e4a04360d559618fa41fdf037a744e4e7c0eb.zip
The directory protocol
Diffstat (limited to '')
-rw-r--r--lib/protocols/Directory.ml16
-rw-r--r--lib/protocols/Directory.mli13
2 files changed, 29 insertions, 0 deletions
diff --git a/lib/protocols/Directory.ml b/lib/protocols/Directory.ml
new file mode 100644
index 0000000..5a2637f
--- /dev/null
+++ b/lib/protocols/Directory.ml
@@ -0,0 +1,16 @@
+class type implementation = object
+ method list : string list
+ method find : string -> Handle.t option
+end
+
+type Handle.protocol += Directory of implementation
+
+type t = implementation
+
+let make impl = Directory impl
+
+let from handle = Handle.into handle (function Directory impl -> Some impl | _ -> None)
+
+let list i = Handle.invoke i (fun o -> o#list)
+
+let find i name = Handle.invoke i (fun o -> o#find name)
diff --git a/lib/protocols/Directory.mli b/lib/protocols/Directory.mli
new file mode 100644
index 0000000..b7bc69c
--- /dev/null
+++ b/lib/protocols/Directory.mli
@@ -0,0 +1,13 @@
+type t
+
+class type implementation = object
+ method list : string list
+ method find : string -> Handle.t option
+end
+
+val make : implementation -> Handle.protocol
+
+val from : Handle.t -> t Handle.interface option
+
+val list : t Handle.interface -> string list
+val find : t Handle.interface -> string -> Handle.t option