Reader small image

You're reading from  Protocol Buffers Handbook

Product typeBook
Published inApr 2024
PublisherPackt
ISBN-139781805124672
Edition1st Edition
Right arrow
Author (1)
Clément Jean
Clément Jean
author image
Clément Jean

Clément Jean is the CTO of Education for Ethiopia, a start-up focusing on educating K-12 students in Ethiopia. On top of that, he is also an online instructor (on Udemy, Linux Foundation, and others) teaching people about diff erent kinds of technologies. In both his occupations, he deals with technologies such as Protobuf and gRPC and how to apply them to real-life use cases. His overall goal is to empower people through education and technology.
Read more about Clément Jean

Right arrow

Encoding data to type with --encode

Now, we will start to see flags that are important for learning Protobuf and inspecting the serialized data. We will start with the flag called --encode.

As its name suggests, the --encode flag is used to encode data. It will take some data and turn it into binary (serialization). This is especially useful at this point in the book because we can inspect data without having to write code yet. We simply need protoc and the knowledge we have on how to write in Protobuf Text Format.

Our goal in this section is not so much understanding the binary produced. We care about generating it first. In the next chapter, we will talk about the binary format. So, let us just write a simple textpb file and encode it with the –-encode flag.

We will have the following textpb file (encode/user.txtpb):

id: 42
name: "Clément"

We will also have the following .proto file (encode/user.proto):

syntax = "proto3";
message User...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Protocol Buffers Handbook
Published in: Apr 2024Publisher: PacktISBN-13: 9781805124672

Author (1)

author image
Clément Jean

Clément Jean is the CTO of Education for Ethiopia, a start-up focusing on educating K-12 students in Ethiopia. On top of that, he is also an online instructor (on Udemy, Linux Foundation, and others) teaching people about diff erent kinds of technologies. In both his occupations, he deals with technologies such as Protobuf and gRPC and how to apply them to real-life use cases. His overall goal is to empower people through education and technology.
Read more about Clément Jean