View source on GitHub
|
Generic supertype for tag serializers.
Each tag serializer describes how to serialize a specific type of tags to its corresponding proto format.
Methods
can_serialize_tag
@abc.abstractmethodcan_serialize_tag( tag: Any ) -> bool
Whether the given tag can be serialized by this serializer.
to_proto
@abc.abstractmethodto_proto( tag, msg=None, *, constants: list[v2.program_pb2.Constant], raw_constants: dict[Any, int] ) -> (v2.program_pb2.Tag | None)
Converts tag to proto using this serializer.
If self.can_serialize_tag(tag) == False, this should return None.
| Args | |
|---|---|
tag
|
The tag to be serialized. |
msg
|
An optional proto object to populate with the serialization results. |
constants
|
The list of previously-serialized Constant protos. |
raw_constants
|
A map raw objects to their respective indices in
constants.
|
| Returns | |
|---|---|
The proto-serialized version of tag. If msg was provided, it is
the returned object.
|
View source on GitHub