package ocaml-protoc-plugin

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

Source file any.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
(********************************************************)
(*           AUTOGENERATED FILE - DO NOT EDIT!          *)
(********************************************************)
(* Generated by: ocaml-protoc-plugin                    *)
(* https://github.com/andersfugmann/ocaml-protoc-plugin *)
(********************************************************)
(*
  Source: google/protobuf/any.proto
  Syntax: proto3
  Parameters:
    debug=false
    annot=''
    opens=[]
    int64_as_int=true
    int32_as_int=true
    fixed_as_int=false
    singleton_record=false
    prefix_output_with_package=false
*)
[@@@ocaml.alert "-protobuf"] (* Disable deprecation warnings for protobuf*)

(**/**)
module Runtime' = Ocaml_protoc_plugin [@@warning "-33"]
module Imported'modules = struct
end
(**/**)
module rec Google : sig
  module rec Protobuf : sig

    (**
      `Any` contains an arbitrary serialized protocol buffer message along with a
      URL that describes the type of the serialized message.

      Protobuf library provides support to pack/unpack Any values in the form
      of utility functions or additional generated methods of the Any type.

      Example 1: Pack and unpack a message in C++.
      {v
           Foo foo = ...;
           Any any;
           any.PackFrom(foo);
           ...
           if (any.UnpackTo(&foo)) {
             ...
           }
      v}
      Example 2: Pack and unpack a message in Java.
      {v
           Foo foo = ...;
           Any any = Any.pack(foo);
           ...
           if (any.is(Foo.class)) {
             foo = any.unpack(Foo.class);
           }
      v}
      Example 3: Pack and unpack a message in Python.
      {v
           foo = Foo(...)
           any = Any()
           any.Pack(foo)
           ...
           if any.Is(Foo.DESCRIPTOR):
             any.Unpack(foo)
             ...
      v}
      Example 4: Pack and unpack a message in Go
      {v
            foo := &pb.Foo{...}
            any, err := anypb.New(foo)
            if err != nil {
              ...
            }
            ...
            foo := &pb.Foo{}
            if err := any.UnmarshalTo(foo); err != nil {
              ...
            }
      v}
      The pack methods provided by protobuf library will by default use
      'type.googleapis.com/full.type.name' as the type URL and the unpack
      methods only use the fully qualified type name after the last '/'
      in the type URL, for example "foo.bar.com/x/y.z" will yield type
      name "y.z".


      JSON

      The JSON representation of an `Any` value uses the regular
      representation of the deserialized, embedded message, with an
      additional field `\@type` which contains the type URL. Example:
      {v
           package google.profile;
           message Person {
             string first_name = 1;
             string last_name = 2;
           }

           {
             "@type": "type.googleapis.com/google.profile.Person",
             "firstName": <string>,
             "lastName": <string>
           }
      v}
      If the embedded message type is well-known and has a custom JSON
      representation, that representation will be embedded adding a field
      `value` which holds the custom JSON in addition to the `\@type`
      field. Example (for message \[google.protobuf.Duration\]\[\]):
      {v
           {
             "@type": "type.googleapis.com/google.protobuf.Duration",
             "value": "1.212s"
           }
      v}
    *)
    module rec Any : sig
      type t = {
      type_url: string;(** A URL/resource name that uniquely identifies the type of the serialized
      protocol buffer message. This string must contain at least
      one "/" character. The last segment of the URL's path must represent
      the fully qualified name of the type (as in
      `path/google.protobuf.Duration`). The name should be in a canonical form
      (e.g., leading "." is not accepted).

      In practice, teams usually precompile into the binary all types that they
      expect it to use in the context of Any. However, for URLs which use the
      scheme `http`, `https`, or no scheme, one can optionally set up a type
      server that maps type URLs to message definitions as follows:

      * If no scheme is provided, `https` is assumed.
      * An HTTP GET on the URL must yield a \[google.protobuf.Type\]\[\]
      {v
         value in binary format, or produce an error.
      v}
      * Applications are allowed to cache lookup results based on the
      {v
         URL, or have them precompiled into a binary to avoid any
         lookup. Therefore, binary compatibility needs to be preserved
         on changes to types. (Use versioned type names to manage
         breaking changes.)
      v}
      Note: this functionality is not currently available in the official
      protobuf release, and it is not used for type URLs beginning with
      type.googleapis.com.

      Schemes other than `http`, `https` (or the empty scheme) might be
      used with implementation specific semantics. *)
      value: bytes;(** Must be a valid serialized protocol buffer of the above specified type. *)
      }
      val make: ?type_url:string -> ?value:bytes -> unit -> t
      (** Helper function to generate a message using default values *)

      val to_proto: t -> Runtime'.Writer.t
      (** Serialize the message to binary format *)

      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from binary format *)

      val to_json: Runtime'.Json_options.t -> t -> Runtime'.Json.t
      (** Serialize to Json (compatible with Yojson.Basic.t) *)

      val from_json: Runtime'.Json.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from Json (compatible with Yojson.Basic.t) *)

      val name: unit -> string
      (** Fully qualified protobuf name of this message *)

      (**/**)
      type make_t = ?type_url:string -> ?value:bytes -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> unit
      val from_proto_exn: Runtime'.Reader.t -> t
      val from_json_exn: Runtime'.Json.t -> t
      (**/**)
    end
  end
end = struct
  module rec Protobuf : sig

    (**
      `Any` contains an arbitrary serialized protocol buffer message along with a
      URL that describes the type of the serialized message.

      Protobuf library provides support to pack/unpack Any values in the form
      of utility functions or additional generated methods of the Any type.

      Example 1: Pack and unpack a message in C++.
      {v
           Foo foo = ...;
           Any any;
           any.PackFrom(foo);
           ...
           if (any.UnpackTo(&foo)) {
             ...
           }
      v}
      Example 2: Pack and unpack a message in Java.
      {v
           Foo foo = ...;
           Any any = Any.pack(foo);
           ...
           if (any.is(Foo.class)) {
             foo = any.unpack(Foo.class);
           }
      v}
      Example 3: Pack and unpack a message in Python.
      {v
           foo = Foo(...)
           any = Any()
           any.Pack(foo)
           ...
           if any.Is(Foo.DESCRIPTOR):
             any.Unpack(foo)
             ...
      v}
      Example 4: Pack and unpack a message in Go
      {v
            foo := &pb.Foo{...}
            any, err := anypb.New(foo)
            if err != nil {
              ...
            }
            ...
            foo := &pb.Foo{}
            if err := any.UnmarshalTo(foo); err != nil {
              ...
            }
      v}
      The pack methods provided by protobuf library will by default use
      'type.googleapis.com/full.type.name' as the type URL and the unpack
      methods only use the fully qualified type name after the last '/'
      in the type URL, for example "foo.bar.com/x/y.z" will yield type
      name "y.z".


      JSON

      The JSON representation of an `Any` value uses the regular
      representation of the deserialized, embedded message, with an
      additional field `\@type` which contains the type URL. Example:
      {v
           package google.profile;
           message Person {
             string first_name = 1;
             string last_name = 2;
           }

           {
             "@type": "type.googleapis.com/google.profile.Person",
             "firstName": <string>,
             "lastName": <string>
           }
      v}
      If the embedded message type is well-known and has a custom JSON
      representation, that representation will be embedded adding a field
      `value` which holds the custom JSON in addition to the `\@type`
      field. Example (for message \[google.protobuf.Duration\]\[\]):
      {v
           {
             "@type": "type.googleapis.com/google.protobuf.Duration",
             "value": "1.212s"
           }
      v}
    *)
    module rec Any : sig
      type t = {
      type_url: string;(** A URL/resource name that uniquely identifies the type of the serialized
      protocol buffer message. This string must contain at least
      one "/" character. The last segment of the URL's path must represent
      the fully qualified name of the type (as in
      `path/google.protobuf.Duration`). The name should be in a canonical form
      (e.g., leading "." is not accepted).

      In practice, teams usually precompile into the binary all types that they
      expect it to use in the context of Any. However, for URLs which use the
      scheme `http`, `https`, or no scheme, one can optionally set up a type
      server that maps type URLs to message definitions as follows:

      * If no scheme is provided, `https` is assumed.
      * An HTTP GET on the URL must yield a \[google.protobuf.Type\]\[\]
      {v
         value in binary format, or produce an error.
      v}
      * Applications are allowed to cache lookup results based on the
      {v
         URL, or have them precompiled into a binary to avoid any
         lookup. Therefore, binary compatibility needs to be preserved
         on changes to types. (Use versioned type names to manage
         breaking changes.)
      v}
      Note: this functionality is not currently available in the official
      protobuf release, and it is not used for type URLs beginning with
      type.googleapis.com.

      Schemes other than `http`, `https` (or the empty scheme) might be
      used with implementation specific semantics. *)
      value: bytes;(** Must be a valid serialized protocol buffer of the above specified type. *)
      }
      val make: ?type_url:string -> ?value:bytes -> unit -> t
      (** Helper function to generate a message using default values *)

      val to_proto: t -> Runtime'.Writer.t
      (** Serialize the message to binary format *)

      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from binary format *)

      val to_json: Runtime'.Json_options.t -> t -> Runtime'.Json.t
      (** Serialize to Json (compatible with Yojson.Basic.t) *)

      val from_json: Runtime'.Json.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from Json (compatible with Yojson.Basic.t) *)

      val name: unit -> string
      (** Fully qualified protobuf name of this message *)

      (**/**)
      type make_t = ?type_url:string -> ?value:bytes -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> unit
      val from_proto_exn: Runtime'.Reader.t -> t
      val from_json_exn: Runtime'.Json.t -> t
      (**/**)
    end
  end = struct
    module rec Any : sig
      type t = {
      type_url: string;(** A URL/resource name that uniquely identifies the type of the serialized
      protocol buffer message. This string must contain at least
      one "/" character. The last segment of the URL's path must represent
      the fully qualified name of the type (as in
      `path/google.protobuf.Duration`). The name should be in a canonical form
      (e.g., leading "." is not accepted).

      In practice, teams usually precompile into the binary all types that they
      expect it to use in the context of Any. However, for URLs which use the
      scheme `http`, `https`, or no scheme, one can optionally set up a type
      server that maps type URLs to message definitions as follows:

      * If no scheme is provided, `https` is assumed.
      * An HTTP GET on the URL must yield a \[google.protobuf.Type\]\[\]
      {v
         value in binary format, or produce an error.
      v}
      * Applications are allowed to cache lookup results based on the
      {v
         URL, or have them precompiled into a binary to avoid any
         lookup. Therefore, binary compatibility needs to be preserved
         on changes to types. (Use versioned type names to manage
         breaking changes.)
      v}
      Note: this functionality is not currently available in the official
      protobuf release, and it is not used for type URLs beginning with
      type.googleapis.com.

      Schemes other than `http`, `https` (or the empty scheme) might be
      used with implementation specific semantics. *)
      value: bytes;(** Must be a valid serialized protocol buffer of the above specified type. *)
      }
      val make: ?type_url:string -> ?value:bytes -> unit -> t
      (** Helper function to generate a message using default values *)

      val to_proto: t -> Runtime'.Writer.t
      (** Serialize the message to binary format *)

      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from binary format *)

      val to_json: Runtime'.Json_options.t -> t -> Runtime'.Json.t
      (** Serialize to Json (compatible with Yojson.Basic.t) *)

      val from_json: Runtime'.Json.t -> (t, [> Runtime'.Result.error]) result
      (** Deserialize from Json (compatible with Yojson.Basic.t) *)

      val name: unit -> string
      (** Fully qualified protobuf name of this message *)

      (**/**)
      type make_t = ?type_url:string -> ?value:bytes -> unit -> t
      val merge: t -> t -> t
      val to_proto': Runtime'.Writer.t -> t -> unit
      val from_proto_exn: Runtime'.Reader.t -> t
      val from_json_exn: Runtime'.Json.t -> t
      (**/**)
    end = struct
      module This'_ = Any
      let name () = ".google.protobuf.Any"
      type t = {
      type_url: string;(** A URL/resource name that uniquely identifies the type of the serialized
      protocol buffer message. This string must contain at least
      one "/" character. The last segment of the URL's path must represent
      the fully qualified name of the type (as in
      `path/google.protobuf.Duration`). The name should be in a canonical form
      (e.g., leading "." is not accepted).

      In practice, teams usually precompile into the binary all types that they
      expect it to use in the context of Any. However, for URLs which use the
      scheme `http`, `https`, or no scheme, one can optionally set up a type
      server that maps type URLs to message definitions as follows:

      * If no scheme is provided, `https` is assumed.
      * An HTTP GET on the URL must yield a \[google.protobuf.Type\]\[\]
      {v
         value in binary format, or produce an error.
      v}
      * Applications are allowed to cache lookup results based on the
      {v
         URL, or have them precompiled into a binary to avoid any
         lookup. Therefore, binary compatibility needs to be preserved
         on changes to types. (Use versioned type names to manage
         breaking changes.)
      v}
      Note: this functionality is not currently available in the official
      protobuf release, and it is not used for type URLs beginning with
      type.googleapis.com.

      Schemes other than `http`, `https` (or the empty scheme) might be
      used with implementation specific semantics. *)
      value: bytes;(** Must be a valid serialized protocol buffer of the above specified type. *)
      }
      type make_t = ?type_url:string -> ?value:bytes -> unit -> t
      let make ?(type_url = {||}) ?(value = (Bytes.of_string {||})) () = { type_url; value }
      let merge =
      let merge_type_url = Runtime'.Merge.merge Runtime'.Spec.( basic ((1, "type_url", "typeUrl"), string, ({||})) ) in
      let merge_value = Runtime'.Merge.merge Runtime'.Spec.( basic ((2, "value", "value"), bytes, ((Bytes.of_string {||}))) ) in
      fun t1 t2 -> {
      type_url = (merge_type_url t1.type_url t2.type_url);
      value = (merge_value t1.value t2.value);
       }
      let spec () = Runtime'.Spec.( basic ((1, "type_url", "typeUrl"), string, ({||})) ^:: basic ((2, "value", "value"), bytes, ((Bytes.of_string {||}))) ^:: nil )
      let to_proto' =
        let serialize = Runtime'.apply_lazy (fun () -> Runtime'.Serialize.serialize (spec ())) in
        fun writer { type_url; value } -> serialize writer type_url value

      let to_proto t = let writer = Runtime'.Writer.init () in to_proto' writer t; writer
      let from_proto_exn =
        let constructor type_url value = { type_url; value } in
        Runtime'.apply_lazy (fun () -> Runtime'.Deserialize.deserialize (spec ()) constructor)
      let from_proto writer = Runtime'.Result.catch (fun () -> from_proto_exn writer)
      let to_json options =
        let serialize = Runtime'.Serialize_json.serialize ~message_name:(name ()) (spec ()) options in
        fun { type_url; value } -> serialize type_url value
      let from_json_exn =
        let constructor type_url value = { type_url; value } in
        Runtime'.apply_lazy (fun () -> Runtime'.Deserialize_json.deserialize ~message_name:(name ()) (spec ()) constructor)
      let from_json json = Runtime'.Result.catch (fun () -> from_json_exn json)
    end
  end
end
OCaml

Innovation. Community. Security.