snarkvm_circuit_program/data/future/
mod.rsmod argument;
pub use argument::Argument;
mod equal;
mod find;
mod to_bits;
mod to_fields;
use crate::{Access, Identifier, Plaintext, ProgramID, Value};
use snarkvm_circuit_network::Aleo;
use snarkvm_circuit_types::{Boolean, Field, U16, environment::prelude::*};
#[derive(Clone)]
pub struct Future<A: Aleo> {
program_id: ProgramID<A>,
function_name: Identifier<A>,
arguments: Vec<Argument<A>>,
}
impl<A: Aleo> Inject for Future<A> {
type Primitive = console::Future<A::Network>;
fn new(mode: Mode, value: Self::Primitive) -> Self {
Self::from(
Inject::new(mode, *value.program_id()),
Inject::new(mode, *value.function_name()),
Inject::new(mode, value.arguments().to_vec()),
)
}
}
impl<A: Aleo> Eject for Future<A> {
type Primitive = console::Future<A::Network>;
fn eject_mode(&self) -> Mode {
let program_id_mode = Eject::eject_mode(self.program_id());
let function_name_mode = Eject::eject_mode(self.function_name());
let inputs_mode = Eject::eject_mode(&self.inputs());
Mode::combine(Mode::combine(program_id_mode, function_name_mode), inputs_mode)
}
fn eject_value(&self) -> Self::Primitive {
Self::Primitive::new(
Eject::eject_value(self.program_id()),
Eject::eject_value(self.function_name()),
self.inputs().iter().map(Eject::eject_value).collect(),
)
}
}
impl<A: Aleo> Future<A> {
#[inline]
pub const fn from(program_id: ProgramID<A>, function_name: Identifier<A>, arguments: Vec<Argument<A>>) -> Self {
Self { program_id, function_name, arguments }
}
#[inline]
pub const fn program_id(&self) -> &ProgramID<A> {
&self.program_id
}
#[inline]
pub const fn function_name(&self) -> &Identifier<A> {
&self.function_name
}
#[inline]
pub fn inputs(&self) -> &[Argument<A>] {
&self.arguments
}
}