plonky2/src/wire.rs

23 lines
589 B
Rust
Raw Normal View History

use std::ops::Range;
2021-02-09 21:25:21 -08:00
2021-06-22 15:34:50 +02:00
use crate::circuit_data::CircuitConfig;
2021-02-09 21:25:21 -08:00
/// Represents a wire in the circuit.
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
pub struct Wire {
/// The index of the associated gate.
pub gate: usize,
/// The index of the gate input wherein this wire is inserted.
pub input: usize,
}
impl Wire {
2021-05-07 11:30:03 +02:00
pub fn is_routable(&self, config: &CircuitConfig) -> bool {
2021-02-09 21:25:21 -08:00
self.input < config.num_routed_wires
}
pub fn from_range(gate: usize, range: Range<usize>) -> Vec<Self> {
range.map(|i| Wire { gate, input: i }).collect()
}
2021-02-09 21:25:21 -08:00
}