Regarding the subject of creating my own data types, I discovered that I can use *FieldOptions* and create a custom plugin in Protocol Buffers. This allows me to define custom *FieldOptions* and apply them to generated fields.
For example, if we have a *bytes* field in a ProtoBuf schema, we can define a *FieldOption* to specify the *offset* and *length* of the field. Then, the generated code can use this *FieldOption* to correctly parse the field in the response. Le lundi 10 mars 2025 à 18:02:53 UTC, Marc Gravell a écrit : > I think this doesn't fit inside any existing wire-type, which means there > is no protocol-compliant way of adding such data. You could create your own > fork that adds a custom wire-type (there are a couple of unused values), > but it would no longer be protobuf and would not be compatible with any > implementation, so you'd also need to rework all the read/write logic on > any platforms that you're using. IMO that would be a terrible idea, and > you'd be better off just using a varint and eating the extra byte for > values in the range 128-255. > > On Mon, 10 Mar 2025, 17:39 jawad arbahi, <[email protected]> wrote: > >> Hello everyone, I want to create my own data types in Protocol Buffers >> (protobuf). For example, I need a UInt8 (1-byte unsigned integer). If I >> want to add this data type, can I use *add-ons* or fork protobuf and >> customize it for my needs? What do you think? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Protocol Buffers" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion visit >> https://groups.google.com/d/msgid/protobuf/0602b674-482e-4da5-a9a6-9031908d27a0n%40googlegroups.com >> >> <https://groups.google.com/d/msgid/protobuf/0602b674-482e-4da5-a9a6-9031908d27a0n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/protobuf/12eca8c1-5147-4ac8-a850-86271c813d35n%40googlegroups.com.
