Skip to main content

Sylk Field

In the Protocol Buffers language, which is used for message serialization/deserialization in Sylk, fields are defined with a field number, a field name, and a field type. The field type can be one of the supported scalar types, such as string, int32, float, etc., or a message type, which is a user-defined type consisting of one or more fields.

In Sylk, you can add any number of fields resource types to be used inside one of the generated messages.

Field Types

Sylk field can be one of many types that are common used in many languages. The field types can be divided into two groups:

  • Primitive fields
  • Non-Primitive (composite) fields

Primitive fields have been finite state of the field data type in any language. Composite fields can vary in their use cases, such "non-primitive" fields can be of other resources such as Mesage / Enum that have been defined in your project schema, or it can be one of the Well Knowns types of google protobuf library which are also defined as resources.

While field type in sylk is derieved from protobuf own internal definitions of field types we had added two additional non-primitive types for simplicity of the schema:

  • Oneof field - an array of possible fields that will be populated in the parent message, only one field can be initialized at a time.
  • Map field - a map of primitive field type as a "Key" and any Primitive or non-primitive "Value"

Field Labels

Each field has its own label whcih will change how this field is compiled in the different languages. Currently we support only "Repeated" label which will turn the field from any of the types available (Primitive and Non-Primitives) to an array or list of the same type.