|  View source on GitHub | 
Generic supertype for operation serializers.
Each operation serializer describes how to serialize a specific type of Cirq operation to its corresponding proto format. Multiple operation types may serialize to the same format.
Methods
can_serialize_operation
@abc.abstractmethodcan_serialize_operation( op: cirq.Operation ) -> bool
Whether the given operation can be serialized by this serializer.
to_proto
@abc.abstractmethodto_proto( op, msg=None, *, constants: list[v2.program_pb2.Constant], raw_constants: dict[Any, int] ) -> (v2.program_pb2.CircuitOperation | v2.program_pb2.Operation | None)
Converts op to proto using this serializer.
If self.can_serialize_operation(op) == false, this should return None.
| Args | |
|---|---|
| op | The Cirq operation 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 op. Ifmsgwas provided, it is
the returned object. |