Skip to main content

Proto3

Why Protocol Buffers?

  • Protocol buffers are Google's language-independent, platform-independent, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
  • You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
  • Protocol Buffers are Schema Of Messages. They are language agnostic.
  • They can be converted to binary and converted back to message formats using the code generated by the protoc compiler for various languages.

Syntax

// Specify the syntax version
syntax = "proto3";

/**
Syntax For Declaring Message:
    message ${MessageName} {
        ${Scalar Value Type} ${FieldName1} = ${Tag Number1};
                .
                .
                .
        ${Scalar Value Type} ${FieldNameN} = ${Tag NumberN};
    }
Default Values Will be applied any case if the message doesn't contain a existing field defined
in the message definition
*/