def circuit_as_schedule_to_protos(circuit: cirq.Circuit) -> Iterator[operations_pb2.Operation]:
    """Convert a circuit into an iterable of protos.

    Args:
        circuit: The circuit to convert to a proto. Must contain only
            gates that can be cast to xmon gates.

    Yields:
        An Operation proto.
    """
    last_picos: int | None = None
    time_picos = 0
    for op in circuit.all_operations():
        if last_picos is None:
            delay = time_picos
        else:
            delay = time_picos - last_picos
        op_proto = gate_to_proto(cast(cirq.Gate, op.gate), op.qubits, delay)
        time_picos += 1
        last_picos = time_picos
        yield op_proto
Convert a circuit into an iterable of protos.

    Args:
        circuit: The circuit to convert to a proto. Must contain only
            gates that can be cast to xmon gates.

    Yields:
        An Operation proto.
    
cirq-google/cirq_google/api/v1/programs.py