package ocaml-protoc

  1. Overview
  2. Docs

Protobuf parse tree

type message_field_label = [
  1. | `Optional
  2. | `Required
  3. | `Repeated
  4. | `Nolabel
]

A field property defining its occurence

type oneof_field_label = unit

Oneof field fields label

Oneof fields have no label, they are simply choices for the oneof fiel they belong to.

type 'a field = {
  1. field_name : string;
  2. field_number : int;
  3. field_label : 'a;
  4. field_type : Pb_field_type.unresolved_t;
  5. field_options : Pb_option.set;
}

message field.

Note this field is parametrized with the label type so that it can be used both by normal field and one of field since the only difference between the 2 is the label.

type message_field = message_field_label field
type oneof_field = oneof_field_label field
type map_field = {
  1. map_name : string;
  2. map_number : int;
  3. map_key_type : Pb_field_type.map_key_type;
  4. map_value_type : Pb_field_type.unresolved_t;
  5. map_options : Pb_option.set;
}
type oneof_body_content =
  1. | Oneof_field of oneof_field
  2. | Oneof_option of Pb_option.t
type oneof = {
  1. oneof_name : string;
  2. oneof_body : oneof_body_content list;
}

oneof entity

type enum_value = {
  1. enum_value_name : string;
  2. enum_value_int : int;
  3. enum_value_options : Pb_option.set;
}
type enum_body_content =
  1. | Enum_value of enum_value
  2. | Enum_option of Pb_option.t
type enum = {
  1. enum_id : int;
  2. enum_name : string;
  3. enum_body : enum_body_content list;
}
type extension_range_to =
  1. | To_max
  2. | To_number of int
type extension_range_from = int
type extension_range =
  1. | Extension_single_number of int
  2. | Extension_range of extension_range_from * extension_range_to
type message_body_content =
  1. | Message_field of message_field
  2. | Message_map_field of map_field
  3. | Message_oneof_field of oneof
  4. | Message_sub of message
  5. | Message_enum of enum
  6. | Message_extension of extension_range list
  7. | Message_reserved of extension_range list
  8. | Message_option of Pb_option.t

Body content defines all the possible consituant of a message.

and message = {
  1. id : int;
  2. message_name : string;
  3. message_body : message_body_content list;
}

Message entity.

Note the ID is simply for uniquely (and easily) identifying a type. It is expected to be generated by a parser. The later compilation functions expects this id to be unique.

type rpc = {
  1. rpc_name : string;
  2. rpc_options : Pb_option.set;
  3. rpc_req_stream : bool;
  4. rpc_req : Pb_field_type.unresolved_t;
  5. rpc_res_stream : bool;
  6. rpc_res : Pb_field_type.unresolved_t;
}
type service_body_content =
  1. | Service_rpc of rpc
  2. | Service_option of Pb_option.t
type service = {
  1. service_name : string;
  2. service_body : service_body_content list;
}
type extend = {
  1. id : int;
  2. extend_name : string;
  3. extend_body : message_field list;
}
type import = {
  1. file_name : string;
  2. public : bool;
}
type proto = {
  1. proto_file_name : string option;
  2. syntax : string option;
  3. imports : import list;
  4. file_options : Pb_option.set;
  5. package : string option;
  6. messages : message list;
  7. services : service list;
  8. enums : enum list;
  9. extends : extend list;
}

Definition of a protobuffer message file.

val pp_message_field_label : Format.formatter -> [< `Nolabel | `Optional | `Repeated | `Required ] -> unit
val pp_oneof_field_label : 'a -> unit -> unit
val pp_field : (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a field -> unit
val pp_message_field : Format.formatter -> [< `Nolabel | `Optional | `Repeated | `Required ] field -> unit
val pp_oneof_field : Format.formatter -> unit field -> unit
val pp_map_field : Format.formatter -> map_field -> unit
val pp_oneof_body_content : Format.formatter -> oneof_body_content -> unit
val pp_oneof : Format.formatter -> oneof -> unit
val pp_enum_value : Format.formatter -> enum_value -> unit
val pp_enum_body_content : Format.formatter -> enum_body_content -> unit
val pp_enum : Format.formatter -> enum -> unit
val pp_extension_range_to : Format.formatter -> extension_range_to -> unit
val pp_extension_range_from : Format.formatter -> int -> unit
val pp_extension_range : Format.formatter -> extension_range -> unit
val pp_message_body_content : Format.formatter -> message_body_content -> unit
val pp_message : Format.formatter -> message -> unit
val pp_rpc : Format.formatter -> rpc -> unit
val pp_service_body_content : Format.formatter -> service_body_content -> unit
val pp_service : Format.formatter -> service -> unit
val pp_extend : Format.formatter -> extend -> unit
val pp_import : Format.formatter -> import -> unit
val pp_proto : Format.formatter -> proto -> unit
OCaml

Innovation. Community. Security.