snarkvm_circuit_program/data/value/
mod.rsmod equal;
mod find;
mod to_bits;
mod to_fields;
use crate::{Access, Entry, Future, Plaintext, Record};
use snarkvm_circuit_network::Aleo;
use snarkvm_circuit_types::{Boolean, Field, environment::prelude::*};
#[derive(Clone)]
pub enum Value<A: Aleo> {
Plaintext(Plaintext<A>),
Record(Record<A, Plaintext<A>>),
Future(Future<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)),
console::Value::Future(future) => Value::Future(Future::new(mode, future)),
}
}
}
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(),
Value::Future(future) => future.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()),
Value::Future(future) => console::Value::Future(future.eject_value()),
}
}
}