Struct Value

Source
pub struct Value {
    pub id: Option<GlobalId>,
    pub(crate) contents: ValueVariants,
}

Fields§

§id: Option<GlobalId>§contents: ValueVariants

Implementations§

Source§

impl Value

Source

pub fn eq(&self, rhs: &Self) -> Result<bool>

Are the values equal, according to SnarkVM?

We use this rather than the Eq trait so we can fail when comparing values of different types, rather than just returning false.

Source

pub fn resolve_if_unsuffixed( &self, ty: &Option<Type>, span: Span, ) -> Result<Value>

Resolves an unsuffixed literal to a typed Value using the provided optional Type. If the value is unsuffixed and a type is provided, parses the string into the corresponding Value variant. Handles integers of various widths and special types like Field, Group, and Scalar. If no type is given or the value is already typed, returns the original value. Returns an error if type inference is not possible or parsing fails.

Source§

impl Value

Source

pub fn lt(&self, rhs: &Self) -> Option<bool>

Source

pub fn lte(&self, rhs: &Self) -> Option<bool>

Source

pub fn gt(&self, rhs: &Self) -> Option<bool>

Source

pub fn gte(&self, rhs: &Self) -> Option<bool>

Source

pub fn inc_wrapping(&self) -> Option<Self>

Source

pub fn add(&self, i: usize) -> Option<Self>

Source

pub fn cast(&self, ty: &Type) -> Option<Self>

Source

pub fn cast_lossy(&self, ty: &LiteralType) -> Option<Self>

Source

pub fn generator() -> Self

Return the group generator.

Source

pub fn as_u32(&self) -> Option<u32>

Source

pub fn as_i128(&self) -> Option<i128>

Source

pub fn array_index(&self, i: usize) -> Option<Self>

Source

pub fn array_index_set(&mut self, i: usize, value: Self) -> Option<()>

Source

pub fn tuple_len(&self) -> Option<usize>

Source

pub fn tuple_index(&self, i: usize) -> Option<Self>

Source

pub fn tuple_index_set(&mut self, i: usize, value: Self) -> Option<()>

Source

pub fn as_future(&self) -> Option<&[AsyncExecution]>

Source

pub fn accesses( &self, accesses: impl IntoIterator<Item = Access<TestnetV0>>, ) -> Option<Value>

Source

fn accesses_impl( &self, accesses: &mut dyn Iterator<Item = Access<TestnetV0>>, ) -> Option<Value>

Source

pub fn member_access(&self, member: Symbol) -> Option<Self>

Source

pub fn member_set(&mut self, member: Symbol, value: Value) -> Option<()>

Source

pub fn make_future( program_name: Symbol, function: Symbol, arguments: impl IntoIterator<Item = Value>, ) -> Option<Value>

Source

fn make_future_impl( program_name: Symbol, function: Symbol, arguments: &mut dyn Iterator<Item = Value>, ) -> Option<Value>

Source

pub fn make_unit() -> Self

Source

pub fn make_struct( contents: impl Iterator<Item = (Symbol, Value)>, program: Symbol, path: Vec<Symbol>, ) -> Self

Source

pub fn make_record( contents: impl Iterator<Item = (Symbol, Value)>, program: Symbol, path: Vec<Symbol>, ) -> Self

Source

pub fn make_array(contents: impl Iterator<Item = Value>) -> Self

Source

pub fn make_tuple(contents: impl IntoIterator<Item = Value>) -> Self

Source

pub fn get_numeric_type(&self) -> Option<Type>

Gets the type of a Value but only if it is an integer, a field, a group, or a scalar. Return None otherwise. These are the only types that an unsuffixed literal can have.

Source

pub fn to_expression( &self, span: Span, node_builder: &NodeBuilder, ty: &Type, struct_lookup: &dyn Fn(&[Symbol]) -> Vec<(Symbol, Type)>, ) -> Option<Expression>

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Value

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Value

Source§

fn default() -> Value

Returns the “default value” for a type. Read more
Source§

impl Display for Value

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Address<TestnetV0>> for Value

Source§

fn from(x: Address<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Boolean<TestnetV0>> for Value

Source§

fn from(x: Boolean<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Field<TestnetV0>> for Value

Source§

fn from(x: Field<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Future<TestnetV0>> for Value

Source§

fn from(value: Future<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Group<TestnetV0>> for Value

Source§

fn from(x: Group<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, i128>> for Value

Source§

fn from(x: I128<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, i16>> for Value

Source§

fn from(x: I16<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, i32>> for Value

Source§

fn from(x: I32<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, i64>> for Value

Source§

fn from(x: I64<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, i8>> for Value

Source§

fn from(x: I8<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, u128>> for Value

Source§

fn from(x: U128<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, u16>> for Value

Source§

fn from(x: U16<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, u32>> for Value

Source§

fn from(x: U32<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, u64>> for Value

Source§

fn from(x: U64<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Integer<TestnetV0, u8>> for Value

Source§

fn from(x: U8<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Literal<TestnetV0>> for Value

Source§

fn from(x: Literal<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Plaintext<TestnetV0>> for Value

Source§

fn from(x: Plaintext<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Scalar<TestnetV0>> for Value

Source§

fn from(x: Scalar<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<Value<TestnetV0>> for Value

Source§

fn from(x: Value<TestnetV0>) -> Self

Converts to this type from the input type.
Source§

impl From<ValueVariants> for Value

Source§

fn from(contents: ValueVariants) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<AsyncExecution>> for Value

Source§

fn from(x: Vec<AsyncExecution>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Value

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Value

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl FromStr for Value

Source§

type Err = ()

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Value

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Value

Source§

fn eq(&self, other: &Value) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryAsRef<Literal<TestnetV0>> for Value

Source§

impl TryAsRef<Plaintext<TestnetV0>> for Value

Source§

impl TryAsRef<bool> for Value

Source§

impl TryAsRef<i128> for Value

Source§

impl TryAsRef<i16> for Value

Source§

impl TryAsRef<i32> for Value

Source§

impl TryAsRef<i64> for Value

Source§

impl TryAsRef<i8> for Value

Source§

impl TryAsRef<u128> for Value

Source§

impl TryAsRef<u16> for Value

Source§

impl TryAsRef<u32> for Value

Source§

impl TryAsRef<u64> for Value

Source§

impl TryAsRef<u8> for Value

Source§

impl TryFrom<Value> for Address<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(x: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Field<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(x: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Group<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(x: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Plaintext<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Scalar<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(x: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for Value<TestnetV0>

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for bool

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<bool, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i128

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<i128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i16

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<i16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i32

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<i32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i64

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<i64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for i8

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<i8, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u128

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<u128, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u16

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<u16, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u32

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<u32, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u64

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<u64, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Value> for u8

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(value: Value) -> Result<u8, Self::Error>

Performs the conversion.
Source§

impl Eq for Value

Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

§

impl !Freeze for Value

§

impl RefUnwindSafe for Value

§

impl Send for Value

§

impl Sync for Value

§

impl Unpin for Value

§

impl UnwindSafe for Value

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T> ToSmolStr for T
where T: Display + ?Sized,

§

fn to_smolstr(&self) -> SmolStr

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

impl<T> ToStringFallible for T
where T: Display,

§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> GraphNode for T
where T: 'static + Clone + Eq + PartialEq + Debug + Hash,