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
(************************************************)
(*       AUTOGENERATED FILE - DO NOT EDIT!      *)
(************************************************)
(* Generated by: ocaml-protoc-plugin            *)
(* https://github.com/issuu/ocaml-protoc-plugin *)
(************************************************)
(*
   Source: google/protobuf/struct.proto
   Syntax: proto3 
   Parameters:
     annot=''
     debug=false
     opens=[]
     int64_as_int=true
     int32_as_int=true
     fixed_as_int=false
     singleton_record=false
*)
module Google = struct
  module Protobuf = struct
    module rec NullValue : sig
      type t = NULL_VALUE 
      val to_int: t -> int
      val from_int: int -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      type t = NULL_VALUE 
      let to_int = function
        | NULL_VALUE -> 0
      
      let from_int = function
        | 0 -> Ok NULL_VALUE
        | n -> Error (`Unknown_enum_value n)
      
    end
    and Struct : sig
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option) 
        val to_proto: t -> Ocaml_protoc_plugin.Writer.t
        val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
      end
      val name': unit -> string
      type t = FieldsEntry.t list 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      module rec FieldsEntry : sig
        val name': unit -> string
        type t = (string * Value.t option) 
        val to_proto: t -> Ocaml_protoc_plugin.Writer.t
        val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
      end = struct 
        let name' () = "Struct.google.protobuf.Struct.FieldsEntry"
        type t = (string * Value.t option) 
        let to_proto = 
          let apply = fun ~f (a, b) -> f a b in
          let spec = Ocaml_protoc_plugin.Serialize.C.( basic (1, string, proto3) ^:: basic_opt (2, (message Value.to_proto)) ^:: nil ) in
          let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
          fun t -> apply ~f:(serialize ()) t
        
        let from_proto = 
          let constructor = fun a b -> (a, b) in
          let spec = Ocaml_protoc_plugin.Deserialize.C.( basic (1, string, proto3) ^:: basic_opt (2, (message Value.from_proto)) ^:: nil ) in
          let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
          fun writer -> deserialize writer
        
      end
      let name' () = "Struct.google.protobuf.Struct"
      type t = FieldsEntry.t list 
      let to_proto = 
        let apply = fun ~f a -> f a in
        let spec = Ocaml_protoc_plugin.Serialize.C.( repeated (1, (message FieldsEntry.to_proto), not_packed) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun a -> a in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( repeated (1, (message FieldsEntry.from_proto), not_packed) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and Value : sig
      val name': unit -> string
      type t = [ `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 to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Struct.google.protobuf.Value"
      type t = [ `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 to_proto = 
        let apply = fun ~f a -> f a in
        let spec = Ocaml_protoc_plugin.Serialize.C.( oneof ((function `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 = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun a -> a in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( oneof ([ oneof_elem (1, (enum NullValue.from_int), 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 Struct.from_proto), fun v -> `Struct_value v); oneof_elem (6, (message ListValue.from_proto), fun v -> `List_value v) ]) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
    and ListValue : sig
      val name': unit -> string
      type t = Value.t list 
      val to_proto: t -> Ocaml_protoc_plugin.Writer.t
      val from_proto: Ocaml_protoc_plugin.Reader.t -> t Ocaml_protoc_plugin.Result.t
    end = struct 
      let name' () = "Struct.google.protobuf.ListValue"
      type t = Value.t list 
      let to_proto = 
        let apply = fun ~f a -> f a in
        let spec = Ocaml_protoc_plugin.Serialize.C.( repeated (1, (message Value.to_proto), not_packed) ^:: nil ) in
        let serialize = Ocaml_protoc_plugin.Serialize.serialize (spec) in
        fun t -> apply ~f:(serialize ()) t
      
      let from_proto = 
        let constructor = fun a -> a in
        let spec = Ocaml_protoc_plugin.Deserialize.C.( repeated (1, (message Value.from_proto), not_packed) ^:: nil ) in
        let deserialize = Ocaml_protoc_plugin.Deserialize.deserialize (spec) constructor in
        fun writer -> deserialize writer
      
    end
  end
end
OCaml

Innovation. Community. Security.