Values#
This page covers the values a client passes as arguments and reads back as results. The encoding of each type is described under Protocol Buffers Encoding.
Scalars#
values-integers [core] [MUST]The integer types are
sint32,sint64,uint32anduint64. An integer of each type arrives intact in both directions. This includes zero, the minimum and maximum, and values past the range of a smaller type or of the integers adoubleholds exactly. A result reads back as an integer.
values-floating-point [core] [MUST]A
doubleorfloatarrives intact in both directions. This includes negative zero, the infinities,NaN, the largest value, the smallest normal value and the smallest subnormal value. A result reads back as a floating point number, also when its value is a whole number.
values-bool [core] [MUST]A
boolarrives intact in both directions.
values-enum [core] [MUST]An enumeration value arrives intact in both directions, also in a list.
values-undeclared-enum-result [core] [MUST]An enumeration result with a value the enumeration does not declare raises the encoding error. The next call succeeds.
Flags Enumerations#
A flags enumeration holds any combination of its values. A number is a value of it when it holds no bit outside the union of the values it declares.
values-flags [core] [MUST]A combination of flags arrives intact in both directions, also in a list, a nullable and a structure.
values-flags-declared-values [core] [MUST]The zero value and a value declared as a union of others decode as the values the enumeration declares.
values-flags-union [core] [MUST]A combination of flags built by the client equals the same combination from the server.
values-flags-contains [core] [MUST]The client tests whether a combination of flags holds a value, and removes a value from a combination.
values-undeclared-flags-result [core] [MUST]A flags enumeration result holding a bit the enumeration does not declare raises the encoding error. The next call succeeds.
values-undeclared-flags-value [dynamic] [MUST]A flags enumeration value holding a bit the enumeration does not declare raises the argument error, before the request is sent.
values-combined-enum-value [dynamic] [MUST]A combination of the values of an enumeration that is not a flags enumeration raises the argument error, before the request is sent.
values-flags-definitions [core] [MUST]The service definitions mark a flags enumeration, and leave other enumerations unmarked.
Strings and Bytes#
values-string [core] [MUST]A string arrives intact in both directions. This includes the empty string, characters outside the Basic Multilingual Plane, combining characters, a byte order mark,
NULand the other control characters, each line ending, and a string over 65,536 bytes.
values-bytes [core] [MUST]Bytes arrive intact in both directions. This includes no bytes, each byte value, data that is not valid UTF-8, and data over 65,536 bytes.
Collections and Structures#
values-collections [core] [MUST]Lists, sets, dictionaries and tuples arrive intact in both directions, including empty and nested ones.
values-collections-of-objects [core] [MUST]Lists, sets, dictionaries and tuples of objects arrive intact in both directions.
values-structures [core] [MUST]Structures, nested structures and collections of structures arrive intact in both directions.
Equality and Ordering#
values-enum-equality [core] [MUST]Two enumeration values with the same value are equal. Values that differ are not.
values-structure-equality [core] [MUST]Two structures with equal fields are equal. Structures that differ in a field are not.
values-structure-hash [core] [MUST]Equal structures hash equal, in a language that hashes values.
values-structure-sorting [ordering] [MUST]Structures order by their fields in turn, as tuples of the same values do. Each of the language’s comparison operators agrees with this order.
Messages#
values-message-result [core] [MUST]A procedure that returns a kRPC protocol message, such as
KRPC.GetServices, returns the decoded message.
Null#
values-nullable [core] [MUST]A parameter or result that can hold null passes and returns both null and a value, for each type.
values-nullable-object [core] [MUST]An object parameter or result that can hold null passes and returns both null and an object, for a procedure, a method and a static method.
values-nullable-fields [core] [MUST]A structure field that can hold null passes and returns both null and a value.
values-nullable-elements [core] [MUST]Null list elements, dictionary values and tuple items arrive intact, also inside another collection or a structure.
values-null-flag [core] [MUST]A null argument or result sets the
is_nullflag and has no value. A null object is never the id 0. A value at a position that can hold null, outside a collection or structure, has no presence bool.
values-null-for-non-nullable [core] [MUST]A null argument for a parameter that cannot hold null raises the encoding or argument error, before the request is sent. This holds for each type the language can pass null for.
values-null-in-non-nullable-slot [core] [MUST]A null in a collection or structure, at a position that cannot hold null, raises the argument error, before the request is sent. Set elements and dictionary keys never hold null.
values-null-result-for-non-nullable [core] [MUST]A null result for a procedure whose return value cannot be null raises the encoding error. The next call succeeds.
values-null-result-with-a-value [core] [MUST]A result with the
is_nullflag set and a value raises the encoding error. The next call succeeds.
Argument Types#
These requirements apply to a dynamically typed language. In a statically typed language, the compiler checks the same.
values-integer-to-float [dynamic] [MUST]An integer passed for a floating point parameter is sent as the nearest value of the parameter’s type. This includes the smallest and largest
sint64and the largestuint64.
values-wrong-type [dynamic] [MUST]A value of the wrong type for its parameter, or for an item of a collection, raises the argument error, before the request is sent. A string that holds a number is not converted to the number, and a bool is not converted to a number.
values-wrong-sized-tuple [dynamic] [MUST]A tuple with the wrong number of items for its parameter raises the encoding or argument error, before the request is sent.
values-out-of-range [dynamic] [MUST]A number outside the range of its parameter’s type raises the encoding or argument error, before the request is sent. This includes a finite
doublebeyond the largestfloat, passed for afloatparameter.
values-undeclared-enum-value [dynamic] [MUST]An enumeration value that the enumeration does not declare raises the encoding or argument error, before the request is sent.
values-wrong-collection [dynamic] [SHOULD]A string, bytes or a dictionary passed for a list, set or tuple raises the argument error, before the request is sent.
Generated Types#
These requirements apply to a client whose generated code holds a service’s enumerations and structures as types. A program uses them with no connection, while the client builds its services from the server’s definitions.
values-declared-values-as-arguments [declarations, definitions] [MUST]An enumeration or structure value made from the generated code, with no connection, passes as an argument.
values-differing-structure-definition [declarations, definitions] [MUST]Where the server’s definition of a structure differs from the generated code, a value made from the generated code does not equal the client’s value of the structure. Passing it as an argument raises the argument error.