pub trait Codegen<'c: 's, 's>: Sized + 's {
type FuncOutput: Lowering;
type Output;
type State: 'c;
type Error: From<LoweringError> + From<Error>;
// Required methods
fn initialize(state: &'s Self::State) -> Self;
fn define_function(
&self,
name: &str,
inputs: usize,
outputs: usize,
) -> Result<Self::FuncOutput, Self::Error>;
fn define_main_function(
&self,
advice_io: &AdviceIO,
instance_io: &InstanceIO,
) -> Result<Self::FuncOutput, Self::Error>;
fn generate_output(self) -> Result<Self::Output, Self::Error>
where Self::Output: 'c;
// Provided methods
fn set_prime_field(&self, prime: Prime) -> Result<(), Self::Error> { ... }
fn define_function_with_body<FN, L, I>(
&self,
name: &str,
inputs: usize,
outputs: usize,
f: FN,
) -> Result<(), Self::Error>
where FN: FnOnce(&Self::FuncOutput, &[Slot], &[Slot]) -> Result<I, Self::Error>,
I: IntoIterator<Item = L>,
L: LowerableStmt { ... }
fn define_main_function_with_body<L>(
&self,
advice_io: &AdviceIO,
instance_io: &InstanceIO,
stmts: impl IntoIterator<Item = L>,
) -> Result<(), Self::Error>
where L: LowerableStmt + Debug { ... }
fn on_scope_end(&self, _: Self::FuncOutput) -> Result<(), Self::Error> { ... }
}Expand description
Implemented by code generators that emit some code representation of the circuit.
Required Associated Types§
Sourcetype FuncOutput: Lowering
type FuncOutput: Lowering
Implementation of the lowering behavior.
Required Methods§
Sourcefn initialize(state: &'s Self::State) -> Self
fn initialize(state: &'s Self::State) -> Self
Initializes the code generator.
Sourcefn define_function(
&self,
name: &str,
inputs: usize,
outputs: usize,
) -> Result<Self::FuncOutput, Self::Error>
fn define_function( &self, name: &str, inputs: usize, outputs: usize, ) -> Result<Self::FuncOutput, Self::Error>
Defines an empty function.
Sourcefn define_main_function(
&self,
advice_io: &AdviceIO,
instance_io: &InstanceIO,
) -> Result<Self::FuncOutput, Self::Error>
fn define_main_function( &self, advice_io: &AdviceIO, instance_io: &InstanceIO, ) -> Result<Self::FuncOutput, Self::Error>
Defines the entrypoint function of the circuit.
Provided Methods§
Sourcefn set_prime_field(&self, prime: Prime) -> Result<(), Self::Error>
fn set_prime_field(&self, prime: Prime) -> Result<(), Self::Error>
Sets the prime field used by the circuit.
By default does nothing.
Sourcefn define_function_with_body<FN, L, I>(
&self,
name: &str,
inputs: usize,
outputs: usize,
f: FN,
) -> Result<(), Self::Error>where
FN: FnOnce(&Self::FuncOutput, &[Slot], &[Slot]) -> Result<I, Self::Error>,
I: IntoIterator<Item = L>,
L: LowerableStmt,
fn define_function_with_body<FN, L, I>(
&self,
name: &str,
inputs: usize,
outputs: usize,
f: FN,
) -> Result<(), Self::Error>where
FN: FnOnce(&Self::FuncOutput, &[Slot], &[Slot]) -> Result<I, Self::Error>,
I: IntoIterator<Item = L>,
L: LowerableStmt,
Defines a function filled with the given body.
Sourcefn define_main_function_with_body<L>(
&self,
advice_io: &AdviceIO,
instance_io: &InstanceIO,
stmts: impl IntoIterator<Item = L>,
) -> Result<(), Self::Error>where
L: LowerableStmt + Debug,
fn define_main_function_with_body<L>(
&self,
advice_io: &AdviceIO,
instance_io: &InstanceIO,
stmts: impl IntoIterator<Item = L>,
) -> Result<(), Self::Error>where
L: LowerableStmt + Debug,
Defines the entrypoint function of the circuit and fills it with the given body.
Sourcefn on_scope_end(&self, _: Self::FuncOutput) -> Result<(), Self::Error>
fn on_scope_end(&self, _: Self::FuncOutput) -> Result<(), Self::Error>
Callback called when a scope ends.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.