diff --git a/src/circuit_json.rs b/src/circuit_json.rs index c4d34b2..d442abc 100644 --- a/src/circuit_json.rs +++ b/src/circuit_json.rs @@ -206,6 +206,7 @@ pub struct ImplicitPermutation(pub Register, pub Register); /// Pytket canonical serialized circuit #[derive(Deserialize, Serialize, Clone, Debug, PartialEq)] +#[non_exhaustive] pub struct SerialCircuit

{ /// The name of the circuit. #[serde(skip_serializing_if = "Option::is_none")] @@ -223,6 +224,12 @@ pub struct SerialCircuit

{ /// Number of wasm wires in the circuit. #[serde(skip_serializing_if = "Option::is_none")] pub number_of_ws: Option, + /// A list of qubits initialized at the start of the circuit. + #[serde(skip_serializing_if = "Option::is_none")] + pub created_qubits: Option>, + /// A list of qubits discarded at the end of the circuit. + #[serde(skip_serializing_if = "Option::is_none")] + pub discarded_qubits: Option>, } impl

Default for Operation

{ @@ -241,6 +248,22 @@ impl

Default for Operation

{ } } +impl Default for SerialCircuit

{ + fn default() -> Self { + Self { + name: None, + phase: Default::default(), + commands: Default::default(), + qubits: Default::default(), + bits: Default::default(), + implicit_permutation: Default::default(), + number_of_ws: None, + created_qubits: None, + discarded_qubits: None, + } + } +} + impl

Operation

{ /// Returns a default-initialized Operation with the given type. /// @@ -289,6 +312,21 @@ impl

Command

{ } impl

SerialCircuit

{ + /// Initialize a new SerialCircuit with the given name and phase. + pub fn new(name: Option, phase: P) -> Self { + Self { + name, + phase, + commands: Vec::new(), + qubits: Vec::new(), + bits: Vec::new(), + implicit_permutation: Vec::new(), + number_of_ws: None, + created_qubits: None, + discarded_qubits: None, + } + } + /// Applies a function over the parameters of the circuit. /// /// Returns a new SerialCircuit with the same data, but with a new generic @@ -308,6 +346,8 @@ impl

SerialCircuit

{ bits: self.bits, implicit_permutation: self.implicit_permutation, number_of_ws: self.number_of_ws, + created_qubits: self.created_qubits, + discarded_qubits: self.discarded_qubits, } } }