Operation

Enum Operation 

Source
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§

Source§

impl<T: WireValue> Operation<T>

Source

pub const VARIANT_COUNT: usize = 10usize

Trait Implementations§

Source§

impl<T: Clone + WireValue> Clone for Operation<T>

Source§

fn clone(&self) -> Operation<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + WireValue> Debug for Operation<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: WireValue> Distribution<Operation<T>> for Standard

Source§

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>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
Source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
Source§

impl From<Operation<bool>> for CombineOperation

Source§

fn from(op: Operation<bool>) -> Self

Converts to this type from the input type.
Source§

impl From<Operation<u64>> for CombineOperation

Source§

fn from(op: Operation<u64>) -> Self

Converts to this type from the input type.
Source§

impl<T: WireValue> HasConst<T> for Operation<T>

Source§

fn constant(&self) -> Option<T>

For gates that include constant data (AddConst, MulConst, etc) provides a method to access the constant. Returns None for all other types of gates.
Source§

impl<T: WireValue> HasIO for Operation<T>

Source§

fn inputs(&self) -> InputIterator<'_, Operation<T>>

Source§

fn outputs(&self) -> OutputIterator<'_, Operation<T>>

Source§

fn dst<'a>(&'a self) -> Option<usize>
where Self: 'a + Sized, OutputIterator<'a, Self>: Iterator<Item = usize>,

For convenience, allows access to the (optional) output, since each gate only ever has one at most.
Source§

impl Identity<bool> for Operation<bool>

Source§

fn is_identity(&self) -> bool

Source§

fn identity(w_out: usize, w_in: usize) -> Self

Used to produce an identity gate on the current field when needed.
Source§

impl Identity<u64> for Operation<u64>

Source§

fn is_identity(&self) -> bool

Source§

fn identity(w_out: usize, w_in: usize) -> Self

Used to produce an identity gate on the current field when needed.
Source§

impl<T: PartialEq + WireValue> PartialEq for Operation<T>

Source§

fn eq(&self, other: &Operation<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Operation<T>
where T: Serialize + WireValue,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: WireValue> Translatable for Operation<T>

Source§

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.
Source§

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.
Source§

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.
Source§

impl<T: Copy + WireValue> Copy for Operation<T>

Source§

impl Gate<bool> for Operation<bool>

Source§

impl Gate<u64> for Operation<u64>

Source§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,