pub struct InitializedGateGraph { /* private fields */ }Expand description
Initialized version of GateGraphBuilder. See GateGraphBuilder for documentation.
Implementations§
Source§impl InitializedGateGraph
 
impl InitializedGateGraph
Sourcepub fn tick(&mut self) -> bool
 
pub fn tick(&mut self) -> bool
Propagates pending state changes through the graph. These could be levers that have been updated or loops. Returns true if the graph has reached a stable state.
Sourcepub fn run_until_stable(&mut self, max: usize) -> Result<usize, &'static str>
 
pub fn run_until_stable(&mut self, max: usize) -> Result<usize, &'static str>
Calls InitializedGateGraph::tick until it returns true a maximum of max times.
Returns Ok(number_of_iterations) if the graph stabilized.
Returns Err(&str) otherwise.
Circuits might not stabilize if they have infinite loops like a chain of 3 not gates.
Sourcepub fn update_levers<I: Iterator<Item = bool>>(
    &mut self,
    levers: &[LeverHandle],
    values: I,
)
 
pub fn update_levers<I: Iterator<Item = bool>>( &mut self, levers: &[LeverHandle], values: I, )
Sets the state of all levers to their corresponding values and calls InitializedGateGraph::tick once.
Sourcepub fn update_lever(&mut self, lever: LeverHandle, value: bool)
 
pub fn update_lever(&mut self, lever: LeverHandle, value: bool)
Sets the state of lever to value and calls InitializedGateGraph::tick once.
Sourcepub fn set_lever(&mut self, lever: LeverHandle)
 
pub fn set_lever(&mut self, lever: LeverHandle)
Sets the state of lever to true and calls InitializedGateGraph::tick once.
Sourcepub fn reset_lever(&mut self, lever: LeverHandle)
 
pub fn reset_lever(&mut self, lever: LeverHandle)
Sets the state of lever to false and calls InitializedGateGraph::tick once.
Sourcepub fn flip_lever(&mut self, lever: LeverHandle)
 
pub fn flip_lever(&mut self, lever: LeverHandle)
Sets the state of lever to the opposite of its current state and calls InitializedGateGraph::tick once.
Sourcepub fn pulse_lever(&mut self, lever: LeverHandle)
 
pub fn pulse_lever(&mut self, lever: LeverHandle)
Sourcepub fn set_lever_stable(&mut self, lever: LeverHandle)
 
pub fn set_lever_stable(&mut self, lever: LeverHandle)
Sets the state of lever to true and calls run_until_stable,
with DEFAULT_STABLE_MAX.
§Panics
Will panic if the circuit does not stabilize
Sourcepub fn reset_lever_stable(&mut self, lever: LeverHandle)
 
pub fn reset_lever_stable(&mut self, lever: LeverHandle)
Sets the state of lever to false and calls run_until_stable,
with DEFAULT_STABLE_MAX.
§Panics
Will panic if the circuit does not stabilize
Sourcepub fn flip_lever_stable(&mut self, lever: LeverHandle)
 
pub fn flip_lever_stable(&mut self, lever: LeverHandle)
Sets the state of lever to the opposite of its current state and calls
run_until_stable, with DEFAULT_STABLE_MAX.
§Panics
Will panic if the circuit does not stabilize
Sourcepub fn pulse_lever_stable(&mut self, lever: LeverHandle)
 
pub fn pulse_lever_stable(&mut self, lever: LeverHandle)
Sets the state of lever to true, calls run_until_stable(DEFAULT_STABLE_MAX),
then sets the state of lever to false and calls run_until_stable(DEFAULT_STABLE_MAX) again.
§Panics
Will panic if the circuit does not stabilize
Sourcepub fn collect_char_lossy(&self, outputs: &[GateIndex]) -> char
 
pub fn collect_char_lossy(&self, outputs: &[GateIndex]) -> char
Returns the corresponding type by collecting its bits from outputs.
If more bits are provided, the value is truncated.
If less bits are provided, the value is 0 extended.