You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What is your use-case and why do you need this feature?
In current implementation packed fields are always presents in the encoded output even collection is empty.
@Serializable
data classPackedIntCarrier(
@ProtoPacked
vall:List<Int>
)
...
@Test
funtestEncodeEmptyPackedList() {
val obj =PackedIntCarrier(emptyList())
val encoded =ProtoBuf.encodeToHexString(obj)
println(encoded)
}
this will prints 0a00 - field 1 with empty length-delimited value
Describe the solution you'd like The protobuf documentation does not explicitly specify how empty fields should be encoded.
Based on the principle that we should try to create messages of the smallest size, and that the Java message class created using the standard com.google.protobuf:protoc compiler also does not write an empty value - we should also stop encoding them.
In this case the output of the previous example should be empty line.
Impact on decoding
The decoding behavior will not change in any way, the input messages "" and "0a00" will give the same result - an empty list in l property.
Impact on nullability
Currently, the null for value for collections cannot be encoded in any way, so this change will not affect the nullability in any way.
The text was updated successfully, but these errors were encountered:
What is your use-case and why do you need this feature?
In current implementation packed fields are always presents in the encoded output even collection is empty.
this will prints
0a00
- field 1 with empty length-delimited valueDescribe the solution you'd like
The protobuf documentation does not explicitly specify how empty fields should be encoded.
Based on the principle that we should try to create messages of the smallest size, and that the Java message class created using the standard
com.google.protobuf:protoc
compiler also does not write an empty value - we should also stop encoding them.In this case the output of the previous example should be empty line.
Impact on decoding
The decoding behavior will not change in any way, the input messages
""
and"0a00"
will give the same result - an empty list inl
property.Impact on nullability
Currently, the null for value for collections cannot be encoded in any way, so this change will not affect the nullability in any way.
The text was updated successfully, but these errors were encountered: