optional_field_get_packed_size() function
Calculate the serialized size of a single optional message field, including the space needed by the preceding tag. Returns 0 if the optional field isn't set.
Arguments
field
Field descriptor for member.
has
True if the field exists, false if not.
Return value
Number of bytes required.