[det]protobuf_serialize_to_codes(+Term:dict,
-MessageType:atom, -WireCodes:list(int))Process a Prolog term into bytes (list of int) that is the serialized
form of a message (designated by MessageType).
Protoc must have been run (with the --swipl_out=
option and the resulting top-level _pb.pl file loaded. For
more details, see the "protoc" section of the overview documentation.
Fails if the term isn't of an appropriate form or if the appropriate
meta-data from protoc hasn't been loaded, or if a field
name is incorrect (and therefore nothing in the meta-data matches it).
| Term | The Prolog form of the data, as nested dicts. |
| MessageType | Fully qualified message name
(from the .proto file's package and message).
For example, if the package is google.protobuf
and the message is FileDescriptorSet, then you would use
'.google.protobuf.FileDescriptorSet' or 'google.protobuf.FileDescriptorSet'.
If there's no package name, use e.g.: 'MyMessage or '.MyMessage'.
You can see the packages by looking at
protobufs:proto_meta_package(Pkg,File,_) and the message
names and fields by
protobufs:proto_meta_field_name('.google.protobuf.FileDescriptorSet', FieldNumber, FieldName, FqnName)
(the initial’.’is not optional for these facts, only for the
top-level name given to protobuf_serialize_to_codes/3). |
| WireCodes | Wire format of the message, which
can be output using
format('~s', [WireCodes]). |
- Errors
- -
version_error(Module-Version) you need to recompile the Module
with a newer version of protoc.
- existence_error if a field can't be found in the meta-data
- See also
library(protobufs): Google's Protocol Buffers (section
1.3.1)
- bug
- -
map fields don't get special treatment (but see protobuf_map_pairs/3).
- oneof is not checked for validity.