1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
mod equal;
mod find;
mod to_bits;
mod to_fields;
use crate::{Entry, Identifier, Plaintext, Record};
use snarkvm_circuit_network::Aleo;
use snarkvm_circuit_types::{environment::prelude::*, Boolean, Field};
#[derive(Clone)]
pub enum Value<A: Aleo> {
Plaintext(Plaintext<A>),
Record(Record<A, Plaintext<A>>),
}
impl<A: Aleo> Inject for Value<A> {
type Primitive = console::Value<A::Network>;
fn new(mode: Mode, value: Self::Primitive) -> Self {
match value {
console::Value::Plaintext(plaintext) => Value::Plaintext(Plaintext::new(mode, plaintext)),
console::Value::Record(record) => Value::Record(Record::new(Mode::Private, record)),
}
}
}
impl<A: Aleo> Eject for Value<A> {
type Primitive = console::Value<A::Network>;
fn eject_mode(&self) -> Mode {
match self {
Value::Plaintext(plaintext) => plaintext.eject_mode(),
Value::Record(record) => record.eject_mode(),
}
}
fn eject_value(&self) -> Self::Primitive {
match self {
Value::Plaintext(plaintext) => console::Value::Plaintext(plaintext.eject_value()),
Value::Record(record) => console::Value::Record(record.eject_value()),
}
}
}