Loads a .proto file.
pb.require(name)
Merges the contents of the specified message into the current message.
This method merges the contents of the specified message into the current message. Singular fields that are set in the specified message overwrite the corresponding fields in the current message. Repeated fields are appended. Singular sub-messages and groups are recursively merged.
msg:MergeFrom(msg2)
Copies the contents of the specified message into the current message.
The method clears the current message and then merges the specified message using MergeFrom.
msg:CopyFrom(msg2)
Clears all data that was set in the message.
msg:Clear()
Checks if the message is initialized.
local is_init, errmsg = msg:IsInitialized()
Merges serialized protocol buffer data into this message.
When we find a field in data
that is already present
in this message:
- If it's a "repeated" field, we append to the end of our list.
- Else, if it's a scalar, we overwrite our field.
- Else, (it's a nonrepeated composite), we recursively merge into the existing composite.
Args:
- data: A serialized message encode in
format
. - format: The optional encoding format of
data
. (defaults to "binary"). - off: Optional offset into
data
. (defaults to 1)
Formats:
- binary
local off = msg:Merge(data, 'text')
Like MergeFromString(), except we clear the object first.
Like Parse(), but accepts messages that are missing required fields.
Serializes the protocol message to a string encoding it using format
.
Args:
- format: The optional serialization format. (defaults to 'binary').
- depth: Optional depth for indenting. (defaults to 0)
Formats:
- binary
- text
local bin, errmsg = msg:Serialize('text')
Serializes the protocol message to a binary string.
This method is similar to SerializeToString but doesn`t check if the message is initialized.
A message will store all unknown fields in field 'unknown_fields'
local unknowns = msg.unknown_fields
for i,v in ipairs(unknowns) do
print("idx =", i, "tag =", v.tag, "wiretype =", v.wire, "value =", v.value)
end