aboutsummaryrefslogtreecommitdiffstats
path: root/lib/concepts/Object.ml
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-08-02 23:38:05 -0300
committerEstevan Castilho <tevo@riajuu.net>2026-08-23 03:06:53 +0000
commitb790c77c5e42a220a8419c69dbea3e392ee60fbe (patch)
tree546d27d92f470d7f90ea7a76b6720039f3ed4291 /lib/concepts/Object.ml
parent8d59f43f445164e8cc8bd3fe1a23bd04e807a6b3 (diff)
downloadRNT-b790c77c5e42a220a8419c69dbea3e392ee60fbe.tar.gz
RNT-b790c77c5e42a220a8419c69dbea3e392ee60fbe.zip
Revert "format"
This reverts commit fee14f4b29840357f87f02d51953f41ce90f7d9e.
Diffstat (limited to '')
-rw-r--r--lib/concepts/Object.ml7
-rw-r--r--lib/concepts/Object.mli4
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/concepts/Object.ml b/lib/concepts/Object.ml
index aacbda6..22fb14a 100644
--- a/lib/concepts/Object.ml
+++ b/lib/concepts/Object.ml
@@ -6,10 +6,13 @@ 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
@@ -48,11 +51,13 @@ module Codec = struct
let to_bencode object_ = Bencode.Tagged (B.tag, Bencode.Dict (B.fields object_))
let of_bencode = function
- | Bencode.Tagged (tag, (Bencode.Dict _ as data)) when Char.equal tag B.tag -> B.of_fields data
+ | Bencode.Tagged (tag, (Bencode.Dict _ as data)) when Char.equal tag B.tag ->
+ B.of_fields data
| _ -> Error (B.malformed ())
let to_blob object_ = to_bencode object_ |> Bencode.to_blob
let of_blob blob = Bencode.of_blob blob |> Utilities.Result.fmap of_bencode
+
let to_bytes object_ = to_blob object_ |> Representation.bytes_of_blob
let of_bytes bytes = Bencode.of_bytes bytes |> Utilities.Result.fmap of_bencode
end
diff --git a/lib/concepts/Object.mli b/lib/concepts/Object.mli
index 7b0c4fd..e132673 100644
--- a/lib/concepts/Object.mli
+++ b/lib/concepts/Object.mli
@@ -4,10 +4,13 @@ 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
@@ -17,6 +20,7 @@ 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 :