package pb

  1. Overview
  2. Docs
Library for describing Protobuf messages

Install

Dune Dependency

Authors

Maintainers

Sources

pb-1.0.0.tbz
sha256=e670f11879ee5e44de396fda26ce18384093fd9d75b33727fe90db073e1e4d01
sha512=d6d5bd2991af3bb0121c6f9620510707e5b25332ff80224a1da482093ed53427b620e01294be4d52637dfedad8c30775ad228ac74a6d579d7c3a1de5887327cc

doc/src/pb/wire_type.ml.html

Source file wire_type.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
(*
 * Copyright (c) 2017 Jeremy Yallop <yallop@docker.com>.
 *
 * This file is distributed under the terms of the MIT License.
 * See the file LICENSE for details.
 *)

type t =
  | Varint
  (** (0) Used for int32, int64, uint32, uint64,
      sint32, sint64, bool, enum *)
  | Sixty_four
  (** (1) Used for fixed64, sfixed64, double *)
  | Length_delimited
  (** (2) Used for string, bytes, embedded messages,
      packed repeated fields *)
  | Start_group
  (** (3) Used for groups (deprecated) *)
  | End_group
  (** (4) Used for groups (deprecated) *)
  | Thirty_two
  (** (5) Used for fixed32, sfixed32, float *)

let of_int = function
  | 0 -> Varint
  | 1 -> Sixty_four
  | 2 -> Length_delimited
  | 3 -> Start_group
  | 4 -> End_group
  | 5 -> Thirty_two
  | n -> Printf.kprintf invalid_arg "Wire_type.of_int (%d)" n

let to_int = function
  | Varint           -> 0
  | Sixty_four       -> 1
  | Length_delimited -> 2
  | Start_group      -> 3
  | End_group        -> 4
  | Thirty_two       -> 5

let to_string = function
  | Varint           -> "Varint"
  | Sixty_four       -> "Sixty_four"
  | Length_delimited -> "Length_delimited"
  | Start_group      -> "Start_group"
  | End_group        -> "End_group"
  | Thirty_two       -> "Thirty_two"

let pp fmt v = Format.pp_print_string fmt (to_string v)

let compare = compare
OCaml

Innovation. Community. Security.