From 919b7f1a81982533ff4ab33730c68313690c2b77 Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Sun, 19 Jan 2025 21:50:01 -0300 Subject: cleanup and format --- lib/schema.ml | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'lib/schema.ml') diff --git a/lib/schema.ml b/lib/schema.ml index b041803..90f8ee1 100644 --- a/lib/schema.ml +++ b/lib/schema.ml @@ -1,33 +1,33 @@ module Protocol = struct open Data_encoding - type attribute = - { name: string; - attr_type: string } - type relation = - { name: string; - attributes: attribute list } + + type attribute = { name : string; attr_type : string } + type relation = { name : string; attributes : attribute list } + let attribute_encoding = - conv - (fun {name; attr_type} -> (name, attr_type)) - (fun (name, attr_type) -> {name; attr_type}) + conv + (fun { name; attr_type } -> (name, attr_type)) + (fun (name, attr_type) -> { name; attr_type }) Data_encoding.(tup2 string string) - + let parse_attribute ~data = let contract_encoding = Data_encoding.(tup2 string string) in match Binary.of_bytes_opt contract_encoding data with - | Some (name, attr_type) -> Ok {name; attr_type} + | Some (name, attr_type) -> Ok { name; attr_type } | None -> Error "Failed to parse attribute" - + let relation_encoding = - conv - (fun {name; attributes} -> (name, attributes)) - (fun (name, attributes) -> {name; attributes}) + conv + (fun { name; attributes } -> (name, attributes)) + (fun (name, attributes) -> { name; attributes }) Data_encoding.(tup2 string (list attribute_encoding)) - + let parse_relation ~data = - let contract_encoding = Data_encoding.(tup2 string (list attribute_encoding)) in + let contract_encoding = + Data_encoding.(tup2 string (list attribute_encoding)) + in match Binary.of_bytes_opt contract_encoding data with - | Some (name, attributes) -> Ok {name; attributes} + | Some (name, attributes) -> Ok { name; attributes } | None -> Error "Failed to parse relation" end @@ -54,4 +54,4 @@ let test_schema_write_and_retrieve() = @@ Binary.of_bytes Protocol.relation_encoding (Bytes.concat Bytes.empty content) in Ok (stream, locations, user_relation) [@@warning "-8"] (* Suppress pattern match incomplete warnings *) -*) \ No newline at end of file +*) -- cgit v1.2.3