From 7bd6a69cea4e57bf79cdf7fcd22619506d3c12c1 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Thu, 30 Jul 2026 17:08:17 -0300 Subject: Serialize runtime objects: Multigroup, Branch & Relation --- lib/concepts/Object.mli | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 lib/concepts/Object.mli (limited to 'lib/concepts/Object.mli') diff --git a/lib/concepts/Object.mli b/lib/concepts/Object.mli new file mode 100644 index 0000000..e132673 --- /dev/null +++ b/lib/concepts/Object.mli @@ -0,0 +1,45 @@ +type bencode = Codec.Bencode.t + +module type S = sig + type t + + val equal : t -> t -> bool + + val to_bencode : t -> bencode + val of_bencode : bencode -> (t, Condition.condition) result + + val to_blob : t -> Representation.blob + val of_blob : Representation.blob -> (t, Condition.condition) result + + val to_bytes : t -> bytes + val of_bytes : bytes -> (t, Condition.condition) result +end + +module type OBJECT = S + +module Field : sig + val string : string -> bencode + val address : Hash.hash -> bencode + + val require_string : string -> bencode -> (string, Condition.condition) result + + val require_address : + malformed:(int -> Condition.condition) -> + string -> + bencode -> + (Hash.hash, Condition.condition) result +end + +module Codec : sig + module type BODY = sig + type t + + val tag : char + val malformed : unit -> Condition.condition + val equal : t -> t -> bool + val fields : t -> (string * bencode) list + val of_fields : bencode -> (t, Condition.condition) result + end + + module Make (B : BODY) : S with type t = B.t +end -- cgit v1.2.3