mod bytes;
mod equal;
mod find;
mod parse;
mod serialize;
mod to_bits;
mod to_fields;
use crate::{Access, Argument, Entry, Future, Literal, Plaintext, Record};
use snarkvm_console_network::Network;
use snarkvm_console_types::prelude::*;
#[derive(Clone)]
pub enum Value<N: Network> {
Plaintext(Plaintext<N>),
Record(Record<N, Plaintext<N>>),
Future(Future<N>),
}
impl<N: Network> From<Literal<N>> for Value<N> {
fn from(literal: Literal<N>) -> Self {
Self::Plaintext(Plaintext::from(literal))
}
}
impl<N: Network> From<&Literal<N>> for Value<N> {
fn from(literal: &Literal<N>) -> Self {
Self::from(Plaintext::from(literal))
}
}
impl<N: Network> From<Plaintext<N>> for Value<N> {
fn from(plaintext: Plaintext<N>) -> Self {
Self::Plaintext(plaintext)
}
}
impl<N: Network> From<&Plaintext<N>> for Value<N> {
fn from(plaintext: &Plaintext<N>) -> Self {
Self::from(plaintext.clone())
}
}
impl<N: Network> From<Record<N, Plaintext<N>>> for Value<N> {
fn from(record: Record<N, Plaintext<N>>) -> Self {
Self::Record(record)
}
}
impl<N: Network> From<&Record<N, Plaintext<N>>> for Value<N> {
fn from(record: &Record<N, Plaintext<N>>) -> Self {
Self::from(record.clone())
}
}
impl<N: Network> From<Future<N>> for Value<N> {
fn from(future: Future<N>) -> Self {
Self::Future(future)
}
}
impl<N: Network> From<&Future<N>> for Value<N> {
fn from(future: &Future<N>) -> Self {
Self::from(future.clone())
}
}
impl<N: Network> From<Argument<N>> for Value<N> {
fn from(argument: Argument<N>) -> Self {
match argument {
Argument::Plaintext(plaintext) => Self::Plaintext(plaintext),
Argument::Future(future) => Self::Future(future),
}
}
}
impl<N: Network> From<&Argument<N>> for Value<N> {
fn from(argument: &Argument<N>) -> Self {
Self::from(argument.clone())
}
}
impl<N: Network> From<&Value<N>> for Value<N> {
fn from(value: &Value<N>) -> Self {
value.clone()
}
}
impl<N: Network> TryFrom<Result<Value<N>>> for Value<N> {
type Error = Error;
fn try_from(value: Result<Value<N>>) -> Result<Self> {
value
}
}
impl<N: Network> TryFrom<String> for Value<N> {
type Error = Error;
fn try_from(value: String) -> Result<Self> {
Self::from_str(&value)
}
}
impl<N: Network> TryFrom<&String> for Value<N> {
type Error = Error;
fn try_from(value: &String) -> Result<Self> {
Self::from_str(value)
}
}
impl<N: Network> TryFrom<&str> for Value<N> {
type Error = Error;
fn try_from(value: &str) -> Result<Self> {
Self::from_str(value)
}
}