moved GateOps

This commit is contained in:
sinuio
2022-01-27 17:45:28 -08:00
parent 149b064af0
commit 10709ceafc
5 changed files with 16 additions and 17 deletions

View File

@@ -1,8 +1,7 @@
pub mod parse;
use crate::element::GateOps;
use crate::errors::CircuitEvalError;
use crate::gate::Gate;
use crate::gate::{Gate, GateOps};
#[derive(Clone, Debug, PartialEq)]
pub struct Circuit {

View File

@@ -1,5 +1,5 @@
use super::GateOps;
use crate::errors::GateOpsError;
use crate::gate::GateOps;
pub type Bool = u8;

View File

@@ -1,12 +0,0 @@
use crate::errors::GateOpsError;
pub trait GateOps: Clone + Copy {
/// XOR `self` and `x`
fn xor(&self, x: &Self) -> Result<Self, GateOpsError>;
/// INV `self`
fn inv(&self) -> Result<Self, GateOpsError>;
/// AND `self` and `x`
fn and(&self, x: &Self) -> Result<Self, GateOpsError>;
}

View File

@@ -1,8 +1,6 @@
mod boolean;
mod gate_ops;
pub use boolean::Bool;
pub use gate_ops::GateOps;
/// An element that has some modulus
pub trait HasModulus {

View File

@@ -1,3 +1,5 @@
use crate::errors::GateOpsError;
/// Basic components of a circuit.
///
/// `id` represents the gate id.
@@ -23,3 +25,15 @@ pub(crate) enum Gate {
zref: usize,
},
}
/// Trait required for implementor to be evaluated in a circuit
pub trait GateOps: Clone + Copy {
/// XOR `self` and `x`
fn xor(&self, x: &Self) -> Result<Self, GateOpsError>;
/// INV `self`
fn inv(&self) -> Result<Self, GateOpsError>;
/// AND `self` and `x`
fn and(&self, x: &Self) -> Result<Self, GateOpsError>;
}