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
(************************************************)
(*       AUTOGENERATED FILE - DO NOT EDIT!      *)
(************************************************)
(* Generated by: ocaml-protoc-plugin            *)
(* https://github.com/issuu/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
*)

open Ocaml_protoc_plugin.Runtime [@@warning "-33"]
module Google = struct
  module Protobuf = struct
    module rec Any : sig
      val name': unit -> string
      type t = { type_url: string; value: bytes } 
      val make : ?type_url:string -> ?value:bytes -> unit -> t
      val to_proto: t -> Runtime'.Writer.t
      val from_proto: Runtime'.Reader.t -> (t, [> Runtime'.Result.error]) result
    end = struct 
      let name' () = "any.google.protobuf.Any"
      type t = { type_url: string; value: bytes }
      let make =
        fun ?type_url ?value () -> 
        let type_url = match type_url with Some v -> v | None -> {||} in
        let value = match value with Some v -> v | None -> (Bytes.of_string {||}) in
        { type_url; value }
      
      let to_proto =
        let apply = fun ~f:f' { type_url; value } -> f' [] type_url value in
        let spec = Runtime'.Serialize.C.( basic (1, string, proto3) ^:: basic (2, bytes, proto3) ^:: nil ) in
        let serialize = Runtime'.Serialize.serialize [] (spec) in
        fun t -> apply ~f:serialize t
      
      let from_proto =
        let constructor = fun _extensions type_url value -> { type_url; value } in
        let spec = Runtime'.Deserialize.C.( basic (1, string, proto3) ^:: basic (2, bytes, proto3) ^:: nil ) in
        let deserialize = Runtime'.Deserialize.deserialize [] spec constructor in
        fun writer -> deserialize writer |> Runtime'.Result.open_error
      
    end
  end
end
OCaml

Innovation. Community. Security.