- protobuf_serialize_to_codes(+Term:dict, -MessageType:atom, -WireCodes:list(int)) is det
- 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).- Arguments:
-
Term - The Prolog form of the data, as nested dicts. MessageType - Fully qualified message name (from the .proto
file'spackage
andmessage
). For example, if thepackage
isgoogle.protobuf
and the message isFileDescriptorSet
, 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 atprotobufs:proto_meta_package(Pkg,File,_)
and the message names and fields byprotobufs: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 theModule
with a newer version ofprotoc
. - - existence_error if a field can't be found in the meta-data
- See also
- -
library(protobufs)
: Google's Protocol Buffers - bug
- -
map
fields don't get special treatment (but see protobuf_map_pairs/3). - -
oneof
is not checked for validity.