InitializedGateGraph

Struct InitializedGateGraph 

Source
pub struct InitializedGateGraph { /* private fields */ }
Expand description

Initialized version of GateGraphBuilder. See GateGraphBuilder for documentation.

Implementations§

Source§

impl InitializedGateGraph

Source

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.

Source

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.

Source

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.

Source

pub fn update_lever(&mut self, lever: LeverHandle, value: bool)

Sets the state of lever to value and calls InitializedGateGraph::tick once.

Source

pub fn set_lever(&mut self, lever: LeverHandle)

Sets the state of lever to true and calls InitializedGateGraph::tick once.

Source

pub fn reset_lever(&mut self, lever: LeverHandle)

Sets the state of lever to false and calls InitializedGateGraph::tick once.

Source

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.

Source

pub fn pulse_lever(&mut self, lever: LeverHandle)

Sets the state of lever to true, calls tick, then sets the state of lever to false and calls tick again.

Source

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

Source

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

Source

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

Source

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

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of gates in the graph.

Source

pub fn dump_dot(&self, filename: &'static str)

Dumps the graph in dot format to path filename, to be visualized by many supported tools, I recommend gephi.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.