Enum snarkvm_console_program::Literal
source · pub enum Literal<N: Network> {
}
Expand description
The literal enum represents all supported types in snarkVM.
Variants§
Address(Address<N>)
The Aleo address type.
Boolean(Boolean<N>)
The boolean type.
Field(Field<N>)
The field type.
Group(Group<N>)
The group type.
I8(I8<N>)
The 8-bit signed integer type.
I16(I16<N>)
The 16-bit signed integer type.
I32(I32<N>)
The 32-bit signed integer type.
I64(I64<N>)
The 64-bit signed integer type.
I128(I128<N>)
The 128-bit signed integer type.
U8(U8<N>)
The 8-bit unsigned integer type.
U16(U16<N>)
The 16-bit unsigned integer type.
U32(U32<N>)
The 32-bit unsigned integer type.
U64(U64<N>)
The 64-bit unsigned integer type.
U128(U128<N>)
The 128-bit unsigned integer type.
Scalar(Scalar<N>)
The scalar type.
String(StringType<N>)
The string type.
Implementations§
source§impl<N: Network> Literal<N>
impl<N: Network> Literal<N>
sourcepub fn downcast(&self, to_type: LiteralType) -> Result<Self>
pub fn downcast(&self, to_type: LiteralType) -> Result<Self>
Downcasts the literal to the given literal type.
This method checks that the downcast does not lose any bits of information, and returns an error if it does.
The hierarchy of downcasting is as follows:
- (
Address
,Group
) ->Field
->Scalar
->Integer
->Boolean
String
(not supported)
sourcepub fn downcast_lossy(&self, to_type: LiteralType) -> Result<Self>
pub fn downcast_lossy(&self, to_type: LiteralType) -> Result<Self>
Downcasts the literal to the given literal type, with lossy truncation.
This method makes a best-effort attempt to preserve upcasting back to the original literal type, but it is not guaranteed to do so.
The hierarchy of downcasting is as follows:
- (
Address
,Group
) ->Field
->Scalar
->Integer
->Boolean
String
(not supported)
source§impl<N: Network> Literal<N>
impl<N: Network> Literal<N>
sourcepub fn from_bits_le(variant: u8, bits_le: &[bool]) -> Result<Self>
pub fn from_bits_le(variant: u8, bits_le: &[bool]) -> Result<Self>
Initializes a new literal from a list of little-endian bits without trailing zeros.
sourcepub fn from_bits_be(variant: u8, bits_be: &[bool]) -> Result<Self>
pub fn from_bits_be(variant: u8, bits_be: &[bool]) -> Result<Self>
Initializes a new literal from a list of big-endian bits without leading zeros.
source§impl<N: Network> Literal<N>
impl<N: Network> Literal<N>
sourcepub fn size_in_bits(&self) -> u16
pub fn size_in_bits(&self) -> u16
Returns the number of bits of this literal.
Trait Implementations§
source§impl<'de, N: Network> Deserialize<'de> for Literal<N>
impl<'de, N: Network> Deserialize<'de> for Literal<N>
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the literal from a string or bytes.
source§impl<N: Network> Parser for Literal<N>
impl<N: Network> Parser for Literal<N>
source§fn parse(string: &str) -> ParserResult<'_, Self>
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into a literal.
source§impl<N: Network> ToBits for &Literal<N>
impl<N: Network> ToBits for &Literal<N>
source§fn to_bits_le(&self) -> Vec<bool>
fn to_bits_le(&self) -> Vec<bool>
Returns the little-endian bits of the literal.
source§fn to_bits_be(&self) -> Vec<bool>
fn to_bits_be(&self) -> Vec<bool>
Returns the big-endian bits of the literal.
source§impl<N: Network> ToBits for Literal<N>
impl<N: Network> ToBits for Literal<N>
source§fn to_bits_le(&self) -> Vec<bool>
fn to_bits_le(&self) -> Vec<bool>
Returns the little-endian bits of the literal.
source§fn to_bits_be(&self) -> Vec<bool>
fn to_bits_be(&self) -> Vec<bool>
Returns the big-endian bits of the literal.
impl<N: Network> Eq for Literal<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for Literal<N>where N: RefUnwindSafe, <N as Environment>::Field: RefUnwindSafe, <N as Environment>::Projective: RefUnwindSafe, <N as Environment>::Scalar: RefUnwindSafe,
impl<N> Send for Literal<N>
impl<N> Sync for Literal<N>
impl<N> Unpin for Literal<N>where N: Unpin, <N as Environment>::Field: Unpin, <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin,
impl<N> UnwindSafe for Literal<N>where N: UnwindSafe, <N as Environment>::Field: UnwindSafe, <N as Environment>::Projective: UnwindSafe, <N as Environment>::Scalar: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,
fn take_from_value<D>( value: &mut Value, field: &str ) -> Result<T, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.