diff options
| author | Marcos Magueta <maguetamarcos@gmail.com> | 2025-01-19 21:50:01 -0300 |
|---|---|---|
| committer | Marcos Magueta <maguetamarcos@gmail.com> | 2025-01-19 21:50:01 -0300 |
| commit | 919b7f1a81982533ff4ab33730c68313690c2b77 (patch) | |
| tree | 81ca1f9779a8af22d505cbc34fe2cba5a3c9c72b /lib/schema.ml | |
| parent | fbb9318eede78561970676c9d98d82e3851aeae5 (diff) | |
| download | Sakura-919b7f1a81982533ff4ab33730c68313690c2b77.tar.gz Sakura-919b7f1a81982533ff4ab33730c68313690c2b77.zip | |
cleanup and format
Diffstat (limited to 'lib/schema.ml')
| -rw-r--r-- | lib/schema.ml | 38 |
1 files changed, 19 insertions, 19 deletions
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 +*) |
