Enum snarkvm_circuit_program::Literal
source · pub enum Literal<A: Aleo> {
Show 16 variants
Address(Address<A>),
Boolean(Boolean<A>),
Field(Field<A>),
Group(Group<A>),
I8(I8<A>),
I16(I16<A>),
I32(I32<A>),
I64(I64<A>),
I128(I128<A>),
U8(U8<A>),
U16(U16<A>),
U32(U32<A>),
U64(U64<A>),
U128(U128<A>),
Scalar(Scalar<A>),
String(StringType<A>),
}
Expand description
The literal enum represents all supported circuit types in snarkVM.
Variants§
Address(Address<A>)
The Aleo address type.
Boolean(Boolean<A>)
The boolean type.
Field(Field<A>)
The field type (base field).
Group(Group<A>)
The group type (affine).
I8(I8<A>)
The 8-bit signed integer type.
I16(I16<A>)
The 16-bit signed integer type.
I32(I32<A>)
The 32-bit signed integer type.
I64(I64<A>)
The 64-bit signed integer type.
I128(I128<A>)
The 128-bit signed integer type.
U8(U8<A>)
The 8-bit unsigned integer type.
U16(U16<A>)
The 16-bit unsigned integer type.
U32(U32<A>)
The 32-bit unsigned integer type.
U64(U64<A>)
The 64-bit unsigned integer type.
U128(U128<A>)
The 128-bit unsigned integer type.
Scalar(Scalar<A>)
The scalar type (scalar field).
String(StringType<A>)
The string type.
Implementations§
source§impl<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
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<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
sourcepub fn from_bits_le(variant: &U8<A>, bits_le: &[Boolean<A>]) -> Self
pub fn from_bits_le(variant: &U8<A>, bits_le: &[Boolean<A>]) -> Self
Initializes a new literal from a list of little-endian bits without trailing zeros.
sourcepub fn from_bits_be(variant: &U8<A>, bits_be: &[Boolean<A>]) -> Self
pub fn from_bits_be(variant: &U8<A>, bits_be: &[Boolean<A>]) -> Self
Initializes a new literal from a list of big-endian bits without leading zeros.
source§impl<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
sourcepub fn size_in_bits(&self) -> U16<A>
pub fn size_in_bits(&self) -> U16<A>
Returns the number of bits of this literal.
source§impl<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
sourcepub fn to_type(&self) -> LiteralType
pub fn to_type(&self) -> LiteralType
Returns the type name of the literal.
Trait Implementations§
source§impl<A: Aleo> Eject for Literal<A>
impl<A: Aleo> Eject for Literal<A>
source§fn eject_mode(&self) -> Mode
fn eject_mode(&self) -> Mode
Ejects the mode of the literal.
source§fn eject_value(&self) -> Self::Primitive
fn eject_value(&self) -> Self::Primitive
Ejects the literal into its primitive.
type Primitive = Literal<<A as Environment>::Network>
§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
true
if the circuit is a constant.§fn is_private(&self) -> bool
fn is_private(&self) -> bool
true
if the circuit is a private.source§impl<A: Aleo> ToBits for &Literal<A>
impl<A: Aleo> ToBits for &Literal<A>
source§fn to_bits_le(&self) -> Vec<Boolean<A>>
fn to_bits_le(&self) -> Vec<Boolean<A>>
Returns the little-endian bits of the literal.
source§fn to_bits_be(&self) -> Vec<Boolean<A>>
fn to_bits_be(&self) -> Vec<Boolean<A>>
Returns the big-endian bits of the literal.
type Boolean = Boolean<A>
source§impl<A: Aleo> ToBits for Literal<A>
impl<A: Aleo> ToBits for Literal<A>
source§fn to_bits_le(&self) -> Vec<Boolean<A>>
fn to_bits_le(&self) -> Vec<Boolean<A>>
Returns the little-endian bits of the literal.
source§fn to_bits_be(&self) -> Vec<Boolean<A>>
fn to_bits_be(&self) -> Vec<Boolean<A>>
Returns the big-endian bits of the literal.