snarkvm_console_program/data/future/
argument.rs1use super::*;
17
18#[derive(Clone)]
20pub enum Argument<N: Network> {
21 Plaintext(Plaintext<N>),
23 Future(Future<N>),
25}
26
27impl<N: Network> Equal<Self> for Argument<N> {
28 type Output = Boolean<N>;
29
30 fn is_equal(&self, other: &Self) -> Self::Output {
32 match (self, other) {
33 (Self::Plaintext(plaintext_a), Self::Plaintext(plaintext_b)) => plaintext_a.is_equal(plaintext_b),
34 (Self::Future(future_a), Self::Future(future_b)) => future_a.is_equal(future_b),
35 (Self::Plaintext(..), _) | (Self::Future(..), _) => Boolean::new(false),
36 }
37 }
38
39 fn is_not_equal(&self, other: &Self) -> Self::Output {
41 match (self, other) {
42 (Self::Plaintext(plaintext_a), Self::Plaintext(plaintext_b)) => plaintext_a.is_not_equal(plaintext_b),
43 (Self::Future(future_a), Self::Future(future_b)) => future_a.is_not_equal(future_b),
44 (Self::Plaintext(..), _) | (Self::Future(..), _) => Boolean::new(true),
45 }
46 }
47}
48
49impl<N: Network> ToBits for Argument<N> {
50 #[inline]
52 fn write_bits_le(&self, vec: &mut Vec<bool>) {
53 match self {
54 Self::Plaintext(plaintext) => {
55 vec.push(false);
56 plaintext.write_bits_le(vec);
57 }
58 Self::Future(future) => {
59 vec.push(true);
60 future.write_bits_le(vec);
61 }
62 }
63 }
64
65 #[inline]
67 fn write_bits_be(&self, vec: &mut Vec<bool>) {
68 match self {
69 Self::Plaintext(plaintext) => {
70 vec.push(false);
71 plaintext.write_bits_be(vec);
72 }
73 Self::Future(future) => {
74 vec.push(true);
75 future.write_bits_be(vec);
76 }
77 }
78 }
79}