snarkvm_circuit_program/data/future/
mod.rs1mod argument;
17pub use argument::Argument;
18
19mod equal;
20mod find;
21mod to_bits;
22mod to_fields;
23
24use crate::{Access, Identifier, Plaintext, ProgramID, Value};
25use snarkvm_circuit_network::Aleo;
26use snarkvm_circuit_types::{Boolean, Field, U16, environment::prelude::*};
27
28#[derive(Clone)]
30pub struct Future<A: Aleo> {
31 program_id: ProgramID<A>,
33 function_name: Identifier<A>,
35 arguments: Vec<Argument<A>>,
37}
38
39impl<A: Aleo> Inject for Future<A> {
40 type Primitive = console::Future<A::Network>;
41
42 fn new(mode: Mode, value: Self::Primitive) -> Self {
44 Self::from(
45 Inject::new(mode, *value.program_id()),
46 Inject::new(mode, *value.function_name()),
47 Inject::new(mode, value.arguments().to_vec()),
48 )
49 }
50}
51
52impl<A: Aleo> Eject for Future<A> {
53 type Primitive = console::Future<A::Network>;
54
55 fn eject_mode(&self) -> Mode {
57 let program_id_mode = Eject::eject_mode(self.program_id());
58 let function_name_mode = Eject::eject_mode(self.function_name());
59 let inputs_mode = Eject::eject_mode(&self.inputs());
60 Mode::combine(Mode::combine(program_id_mode, function_name_mode), inputs_mode)
61 }
62
63 fn eject_value(&self) -> Self::Primitive {
65 Self::Primitive::new(
66 Eject::eject_value(self.program_id()),
67 Eject::eject_value(self.function_name()),
68 self.inputs().iter().map(Eject::eject_value).collect(),
69 )
70 }
71}
72
73impl<A: Aleo> Future<A> {
74 #[inline]
76 pub const fn from(program_id: ProgramID<A>, function_name: Identifier<A>, arguments: Vec<Argument<A>>) -> Self {
77 Self { program_id, function_name, arguments }
78 }
79
80 #[inline]
82 pub const fn program_id(&self) -> &ProgramID<A> {
83 &self.program_id
84 }
85
86 #[inline]
88 pub const fn function_name(&self) -> &Identifier<A> {
89 &self.function_name
90 }
91
92 #[inline]
94 pub fn inputs(&self) -> &[Argument<A>] {
95 &self.arguments
96 }
97}