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§
Source§impl<'de, T> Deserialize<'de> for Operation<T>where
T: Deserialize<'de> + WireValue,
impl<'de, T> Deserialize<'de> for Operation<T>where
T: Deserialize<'de> + WireValue,
Source§fn 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
Source§impl<T: WireValue> Distribution<Operation<T>> for Standard
impl<T: WireValue> Distribution<Operation<T>> for Standard
Source§fn 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.Source§fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
Create an iterator that generates random values of
T, using rng as
the source of randomness. Read moreSource§impl<T: WireValue> HasIO for Operation<T>
impl<T: WireValue> HasIO for Operation<T>
Source§impl<T: WireValue> Translatable for Operation<T>
impl<T: WireValue> Translatable for Operation<T>
Source§fn translate<'a, I1, I2>(&self, win: I1, wout: I2) -> Option<Self>
fn translate<'a, I1, I2>(&self, win: I1, wout: I2) -> Option<Self>
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.
Source§fn translate_from_hashmap<'a>(
&'a self,
translation_table: HashMap<usize, usize>,
) -> Option<Self>
fn translate_from_hashmap<'a>( &'a self, translation_table: HashMap<usize, usize>, ) -> Option<Self>
Takes a hashmap, and looks for existing wires in the keys. Replaces any existing wire keys
with the value from the hashmap.
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> Freeze for Operation<T>where
T: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more