rustiq_core/structures/
metric.rs1use super::CliffordCircuit;
2#[derive(Debug, Clone)]
3pub enum Metric {
4 COUNT,
5 DEPTH,
6}
7
8impl Metric {
9 pub fn from_string(name: &str) -> Result<Self, String> {
11 match name {
12 "depth" => Result::Ok(Self::DEPTH),
13 "count" => Result::Ok(Self::COUNT),
14 &_ => Result::Err(format!("Unknown metric name `{}`", name)),
15 }
16 }
17
18 pub fn on_circuit(&self, circuit: &CliffordCircuit) -> usize {
19 match self {
20 Self::DEPTH => circuit.entangling_depth(),
21 Self::COUNT => circuit.entangling_count(),
22 }
23 }
24}