Ocaml_protoc_compiler_lib.Pb_optionProtobuf File/Message/Field options
This module represents "compiled" option set, which is high level representation, as opposed to low-level representation in Pb_raw_option module.
For the following "raw" set of options:
option (google.api.http).custom.kind = "FETCH";
option (google.api.http).custom.path = "/foo/bar/baz/{id}";
option (google.api.http).additional_bindings = {
get: "/foo/bar/baz/{id}"
};
option (google.api.http).additional_bindings = {
post: "/foo/bar/baz/"
body: "*"
};The "compiled" representation will have only one option (google.api.http), which is a message:
option (google.api.http) = {
custom: {
kind: "FETCH"
path: "/foo/bar/baz/{id}"
}
additional_bindings: [
{
get: "/foo/bar/baz/{id}"
},
{
post: "/foo/bar/baz/"
body: "*"
}
]
};Option normalization is happening in Pb_typing_validation.normalize_option, destructured field assigments are normalized back to nested messages. See Pb_typing_validation.compile_option to see the full process of option compilation.
type constant = Pbrt_options.constant = Protobuf constant
As defined in: Protobuf Language Spec.
type message_literal = (string * value) listand list_literal = value listand value = Pbrt_options.value = | Scalar_value of constant| Message_literal of message_literal| List_literal of list_literaltype t = option_name * valuetype set = t listCompiled collection of options
val stringify_option_name : option_name -> stringval empty : setval add : set -> option_name -> value -> setadd set name value adds option (name, value) into the set. Option name and value are expected to be normalized (see Pb_typing_validation.normalize_option). add is merging nested message literals within option value with the ones that were previously added to the set.
val get : set -> option_name -> value optionget_ext set name is a helper that retrieves Extension_name name option from set
val pp_constant : Format.formatter -> constant -> unitval pp_value : Format.formatter -> value -> unitval pp_message_literal : Format.formatter -> message_literal -> unitval pp_message_field : Format.formatter -> (string * value) -> unitval pp_t : Format.formatter -> t -> unitval pp_set : Format.formatter -> set -> unit