Hi,

I am currently looking at ways of extending the generated code, in order to
add some helpers for some messages which map to standard types in our
codebase (think UUID, IPv6 — akin to the extended features awarded to the
well-known types).


My goal is to be able to go from:

message User {
 example.wellknown.UUID id = 1;
}

To (for Python):

user.id.to_uuid()
UUID("4fc93ada-dded-4737-9a5c-e3811c37f99d")
user.id.from_uuid(UUID("002ce13b-31bc-4332-80f9-51f83a49eb65"))


I thought it would be possible to provide, for my own types, the same kind
of extended features as the "well-known types" enjoy.
However, I couldn't find how to do that in the documentation; and a look
at the Python implementation showed that these extensions are hardcoded in
the codebase (see https://github.com/protocolbuffers/protobuf/blob/master/python/google/protobuf/internal/python_message.py#L151-L152).

Have I missed some part of the documentation? What is the common pattern
for such extensions?

Thanks,

--
Raphaël Barrois

--
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 protobuf+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/a591a464-ab78-47a5-b837-29d6fdec310c%40gmail.com.

Reply via email to