package ocaml-protoc-plugin

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file struct.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
(********************************************************)
(*           AUTOGENERATED FILE - DO NOT EDIT!          *)
(********************************************************)
(* Generated by: ocaml-protoc-plugin                    *)
(* https://github.com/andersfugmann/ocaml-protoc-plugin *)
(********************************************************)
(*
  Source: google/protobuf/struct.proto
  Syntax: proto3
  Parameters:
    debug=false
    annot=''
    opens=[]
    int64_as_int=true
    int32_as_int=true
    fixed_as_int=false
    singleton_record=false
*)

open Ocaml_protoc_plugin.Runtime [@@warning "-33"]
module rec Google : sig
  module rec Protobuf : sig
    module rec NullValue : sig
      type t = NULL_VALUE
      val to_int: t -> int
      val from_int: int -> t Runtime'.Result.t
      val from_int_exn: int -> t
    end
    and Struct : sig
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option)
        val make: ?key:string -> ?value:Value.t -> unit -> t
        val merge: t -> t -> t
        val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
        val to_proto: t -> Runtime'.Writer.t
        val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
        val from_proto_exn: Runtime'.Reader.t -> t
      end
      val name': unit -> string
      type t = (FieldsEntry.t list)
      val make: ?fields:FieldsEntry.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
    and Value : sig
      val name': unit -> string
      type t = ([ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ])
      val make: ?kind:[ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ] -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
    and ListValue : sig
      val name': unit -> string
      type t = (Value.t list)
      val make: ?values:Value.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
  end
end = struct
  module rec Protobuf : sig
    module rec NullValue : sig
      type t = NULL_VALUE
      val to_int: t -> int
      val from_int: int -> t Runtime'.Result.t
      val from_int_exn: int -> t
    end
    and Struct : sig
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option)
        val make: ?key:string -> ?value:Value.t -> unit -> t
        val merge: t -> t -> t
        val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
        val to_proto: t -> Runtime'.Writer.t
        val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
        val from_proto_exn: Runtime'.Reader.t -> t
      end
      val name': unit -> string
      type t = (FieldsEntry.t list)
      val make: ?fields:FieldsEntry.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
    and Value : sig
      val name': unit -> string
      type t = ([ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ])
      val make: ?kind:[ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ] -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
    and ListValue : sig
      val name': unit -> string
      type t = (Value.t list)
      val make: ?values:Value.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end
  end = struct
    module rec NullValue : sig
      type t = NULL_VALUE
      val to_int: t -> int
      val from_int: int -> t Runtime'.Result.t
      val from_int_exn: int -> t
    end = struct
      type t = NULL_VALUE
      let to_int = function
        | NULL_VALUE -> 0

      let from_int_exn = function
        | 0 -> NULL_VALUE
        | n -> Runtime'.Result.raise (`Unknown_enum_value n)

      let from_int e = Runtime'.Result.catch (fun () -> from_int_exn e)
    end
    and Struct : sig
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option)
        val make: ?key:string -> ?value:Value.t -> unit -> t
        val merge: t -> t -> t
        val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
        val to_proto: t -> Runtime'.Writer.t
        val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
        val from_proto_exn: Runtime'.Reader.t -> t
      end
      val name': unit -> string
      type t = (FieldsEntry.t list)
      val make: ?fields:FieldsEntry.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end = struct
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option)
        val make: ?key:string -> ?value:Value.t -> unit -> t
        val merge: t -> t -> t
        val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
        val to_proto: t -> Runtime'.Writer.t
        val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
        val from_proto_exn: Runtime'.Reader.t -> t
      end = struct
        let name' () = "struct.google.protobuf.Struct.FieldsEntry"
        type t = (string * Value.t option)
        let make ?(key = {||}) ?value () = (key, value)
        let merge = (fun (t1_key,t1_value) (t2_key,t2_value) -> (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic (1, string, ({||})) ) t1_key t2_key,Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_opt (2, (message ((fun writer -> Value.from_proto_exn writer), Value.merge))) ) t1_value t2_value))
        let to_proto' =
          let spec = Runtime'.Serialize.C.( basic (1, string, ({||})) ^:: basic_opt (2, (message Value.to_proto')) ^:: nil ) in
          let serialize = Runtime'.Serialize.serialize spec in
          fun writer (key, value) -> serialize writer key value

        let to_proto t = to_proto' (Runtime'.Writer.init ()) t
        let from_proto_exn =
          let constructor = fun key value -> (key, value) in
          let spec = Runtime'.Deserialize.C.( basic (1, string, ({||})) ^:: basic_opt (2, (message ((fun writer -> Value.from_proto_exn writer), Value.merge))) ^:: nil ) in
          Runtime'.Deserialize.deserialize spec constructor
        let from_proto writer = Runtime'.Result.catch (fun () -> from_proto_exn writer)
      end
      let name' () = "struct.google.protobuf.Struct"
      type t = (FieldsEntry.t list)
      let make ?(fields = []) () = (fields)
      let merge = (fun (t1_fields) (t2_fields) -> (Runtime'.Merge.merge Runtime'.Deserialize.C.( repeated (1, (message ((fun writer -> FieldsEntry.from_proto_exn writer), FieldsEntry.merge)), not_packed) ) t1_fields t2_fields))
      let to_proto' =
        let spec = Runtime'.Serialize.C.( repeated (1, (message FieldsEntry.to_proto'), not_packed) ^:: nil ) in
        let serialize = Runtime'.Serialize.serialize spec in
        serialize

      let to_proto t = to_proto' (Runtime'.Writer.init ()) t
      let from_proto_exn =
        let constructor = fun fields -> (fields) in
        let spec = Runtime'.Deserialize.C.( repeated (1, (message ((fun writer -> FieldsEntry.from_proto_exn writer), FieldsEntry.merge)), not_packed) ^:: nil ) in
        Runtime'.Deserialize.deserialize spec constructor
      let from_proto writer = Runtime'.Result.catch (fun () -> from_proto_exn writer)
    end
    and Value : sig
      val name': unit -> string
      type t = ([ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ])
      val make: ?kind:[ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ] -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end = struct
      let name' () = "struct.google.protobuf.Value"
      type t = ([ `not_set | `Null_value of NullValue.t | `Number_value of float | `String_value of string | `Bool_value of bool | `Struct_value of Struct.t | `List_value of ListValue.t ])
      let make ?(kind = `not_set) () = (kind)
      let merge = (fun (t1_kind) (t2_kind) -> (match ((t1_kind), (t2_kind)) with
          | (`Null_value v1, `Null_value v2) -> `Null_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, (enum NullValue.from_int_exn)) ) v1 v2)
          | (`Number_value v1, `Number_value v2) -> `Number_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, double) ) v1 v2)
          | (`String_value v1, `String_value v2) -> `String_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, string) ) v1 v2)
          | (`Bool_value v1, `Bool_value v2) -> `Bool_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, bool) ) v1 v2)
          | (`Struct_value v1, `Struct_value v2) -> `Struct_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, (message ((fun writer -> Struct.from_proto_exn writer), Struct.merge))) ) v1 v2)
          | (`List_value v1, `List_value v2) -> `List_value (Runtime'.Merge.merge Runtime'.Deserialize.C.( basic_req (0, (message ((fun writer -> ListValue.from_proto_exn writer), ListValue.merge))) ) v1 v2)
          | (v1, `not_set)  -> v1
          | (_, v2) -> v2))
      let to_proto' =
        let spec = Runtime'.Serialize.C.( oneof ((function | `not_set -> failwith "This case should never _ever_ happen" | `Null_value v -> oneof_elem (1, (enum NullValue.to_int), v) | `Number_value v -> oneof_elem (2, double, v) | `String_value v -> oneof_elem (3, string, v) | `Bool_value v -> oneof_elem (4, bool, v) | `Struct_value v -> oneof_elem (5, (message Struct.to_proto'), v) | `List_value v -> oneof_elem (6, (message ListValue.to_proto'), v))) ^:: nil ) in
        let serialize = Runtime'.Serialize.serialize spec in
        serialize

      let to_proto t = to_proto' (Runtime'.Writer.init ()) t
      let from_proto_exn =
        let constructor = fun kind -> (kind) in
        let spec = Runtime'.Deserialize.C.( oneof ([ oneof_elem (1, (enum NullValue.from_int_exn), fun v -> `Null_value v); oneof_elem (2, double, fun v -> `Number_value v); oneof_elem (3, string, fun v -> `String_value v); oneof_elem (4, bool, fun v -> `Bool_value v); oneof_elem (5, (message ((fun writer -> Struct.from_proto_exn writer), Struct.merge)), fun v -> `Struct_value v); oneof_elem (6, (message ((fun writer -> ListValue.from_proto_exn writer), ListValue.merge)), fun v -> `List_value v) ]) ^:: nil ) in
        Runtime'.Deserialize.deserialize spec constructor
      let from_proto writer = Runtime'.Result.catch (fun () -> from_proto_exn writer)
    end
    and ListValue : sig
      val name': unit -> string
      type t = (Value.t list)
      val make: ?values:Value.t list -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> Runtime'.Writer.t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      val from_proto_exn: Runtime'.Reader.t -> t
    end = struct
      let name' () = "struct.google.protobuf.ListValue"
      type t = (Value.t list)
      let make ?(values = []) () = (values)
      let merge = (fun (t1_values) (t2_values) -> (Runtime'.Merge.merge Runtime'.Deserialize.C.( repeated (1, (message ((fun writer -> Value.from_proto_exn writer), Value.merge)), not_packed) ) t1_values t2_values))
      let to_proto' =
        let spec = Runtime'.Serialize.C.( repeated (1, (message Value.to_proto'), not_packed) ^:: nil ) in
        let serialize = Runtime'.Serialize.serialize spec in
        serialize

      let to_proto t = to_proto' (Runtime'.Writer.init ()) t
      let from_proto_exn =
        let constructor = fun values -> (values) in
        let spec = Runtime'.Deserialize.C.( repeated (1, (message ((fun writer -> Value.from_proto_exn writer), Value.merge)), not_packed) ^:: nil ) in
        Runtime'.Deserialize.deserialize spec constructor
      let from_proto writer = Runtime'.Result.catch (fun () -> from_proto_exn writer)
    end
  end
end
OCaml

Innovation. Community. Security.