pub enum Operation<T: WireValue> {
Input(usize),
Random(usize),
Add(usize, usize, usize),
AddConst(usize, usize, T),
Sub(usize, usize, usize),
SubConst(usize, usize, T),
Mul(usize, usize, usize),
MulConst(usize, usize, T),
AssertZero(usize),
Const(usize, T),
}
Expand description
Defines the individual logic gate operations we can support
Variants
Input(usize)
Read a value from input and emit it on the wire
Random(usize)
Emit a random value on the wire
Add(usize, usize, usize)
Add the two wires together
AddConst(usize, usize, T)
Add the wire and the constant
Sub(usize, usize, usize)
Subtract the final wire from the second wire
SubConst(usize, usize, T)
Subtract the constant value from the wire
Mul(usize, usize, usize)
Multiply the two wires together
MulConst(usize, usize, T)
Multiply the first wire by the constant value
AssertZero(usize)
Assert that the wire has the const value zero
Const(usize, T)
Emit the const value on the wire
Implementations
Trait Implementations
sourceimpl<'de, T: WireValue> Deserialize<'de> for Operation<T> where
T: Deserialize<'de>,
impl<'de, T: WireValue> Deserialize<'de> for Operation<T> where
T: Deserialize<'de>,
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<T: WireValue> Distribution<Operation<T>> for Standard where
Standard: Distribution<(usize, usize, usize, T)>,
impl<T: WireValue> Distribution<Operation<T>> for Standard where
Standard: Distribution<(usize, usize, usize, T)>,
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Operation<T>
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Operation<T>
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
sourceimpl From<Operation<bool>> for CombineOperation
impl From<Operation<bool>> for CombineOperation
sourceimpl From<Operation<u64>> for CombineOperation
impl From<Operation<u64>> for CombineOperation
sourceimpl<T: WireValue> HasIO for Operation<T>
impl<T: WireValue> HasIO for Operation<T>
sourceimpl<T: WireValue> Translatable for Operation<T>
impl<T: WireValue> Translatable for Operation<T>
sourcefn translate<'a, I1, I2>(&self, win: I1, wout: I2) -> Option<Self> where
Self: Sized,
I1: Iterator<Item = usize>,
I2: Iterator<Item = usize>,
fn translate<'a, I1, I2>(&self, win: I1, wout: I2) -> Option<Self> where
Self: Sized,
I1: Iterator<Item = usize>,
I2: Iterator<Item = usize>,
takes an iterator of input wires and an iterator of output wires, and creates a new gate of the same type using the inputs and outputs. The current input and output wires have no bearing on the new wires, just the gate type. Read more
sourcefn translate_from_hashmap<'a>(
&'a self,
translation_table: HashMap<usize, usize>
) -> Option<Self> where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
fn translate_from_hashmap<'a>(
&'a self,
translation_table: HashMap<usize, usize>
) -> Option<Self> where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
Takes a hashmap, and looks for existing wires in the keys. Replaces any existing wire keys with the value from the hashmap. Read more
sourcefn translate_from_fn<'a>(
&'a self,
input_mapper: fn(_: usize) -> usize,
output_mapper: fn(_: usize) -> usize
) -> Option<Self> where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
fn translate_from_fn<'a>(
&'a self,
input_mapper: fn(_: usize) -> usize,
output_mapper: fn(_: usize) -> usize
) -> Option<Self> where
Self: Sized + HasIO,
InputIterator<'a, Self>: Iterator<Item = usize>,
OutputIterator<'a, Self>: Iterator<Item = usize>,
Calls a function on the I/O wires and replaces them with the output of the function.
impl<T: Copy + WireValue> Copy for Operation<T>
impl Gate<bool> for Operation<bool>
impl Gate<u64> for Operation<u64>
impl<T: WireValue> StructuralPartialEq for Operation<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for Operation<T> where
T: RefUnwindSafe,
impl<T> Send for Operation<T> where
T: Send,
impl<T> Sync for Operation<T> where
T: Sync,
impl<T> Unpin for Operation<T> where
T: Unpin,
impl<T> UnwindSafe for Operation<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more