pub enum Literal<A: Aleo> {
}
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).
Signature(Box<Signature<A>>)
The signature type.
String(StringType<A>)
The string type.
Implementations§
Source§impl<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
Sourcepub fn cast(&self, to_type: LiteralType) -> Result<Self>
pub fn cast(&self, to_type: LiteralType) -> Result<Self>
Casts the literal to the given literal type.
This method checks that the cast does not lose any bits of information, and returns an error if it does.
The hierarchy of casting is as follows:
- (
Address
,Group
) <->Field
<->Scalar
<->Integer
<->Boolean
Signature
(not supported)String
(not supported)
Note that casting to left along the hierarchy always preserves information.
Source§impl<A: Aleo> Literal<A>
impl<A: Aleo> Literal<A>
Sourcepub fn cast_lossy(&self, to_type: LiteralType) -> Result<Self>
pub fn cast_lossy(&self, to_type: LiteralType) -> Result<Self>
Casts the literal to the given literal type, with lossy truncation.
This method makes a best-effort attempt to preserve all bits of information, but it is not guaranteed to do so.
The hierarchy of casting is as follows:
- (
Address
,Group
) <->Field
<->Scalar
<->Integer
<->Boolean
Signature
(not supported)String
(not supported)
Note that casting to left along the hierarchy always preserves information.
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>
Source§fn eject(&self) -> (Mode, Self::Primitive)
fn eject(&self) -> (Mode, Self::Primitive)
Source§fn is_constant(&self) -> bool
fn is_constant(&self) -> bool
true
if the circuit is a constant.Source§fn is_private(&self) -> bool
fn is_private(&self) -> bool
true
if the circuit is a private.Source§impl<A: Aleo> Parser for Literal<A>
impl<A: Aleo> Parser for Literal<A>
Source§fn parse(string: &str) -> ParserResult<'_, Self>
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into a literal.
Source§impl<A: Aleo> ToBits for &Literal<A>
impl<A: Aleo> ToBits for &Literal<A>
Source§fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>)
fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>)
Returns the little-endian bits of the literal.
Source§fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>)
fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>)
Returns the big-endian bits of the literal.
type Boolean = Boolean<A>
Source§fn to_bits_le(&self) -> Vec<Self::Boolean>
fn to_bits_le(&self) -> Vec<Self::Boolean>
Source§fn to_bits_be(&self) -> Vec<Self::Boolean>
fn to_bits_be(&self) -> Vec<Self::Boolean>
Source§impl<A: Aleo> ToBits for Literal<A>
impl<A: Aleo> ToBits for Literal<A>
Source§fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>)
fn write_bits_le(&self, vec: &mut Vec<Boolean<A>>)
Returns the little-endian bits of the literal.
Source§fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>)
fn write_bits_be(&self, vec: &mut Vec<Boolean<A>>)
Returns the big-endian bits of the literal.
type Boolean = Boolean<A>
Source§fn to_bits_le(&self) -> Vec<Self::Boolean>
fn to_bits_le(&self) -> Vec<Self::Boolean>
Source§fn to_bits_be(&self) -> Vec<Self::Boolean>
fn to_bits_be(&self) -> Vec<Self::Boolean>
Auto Trait Implementations§
impl<A> !Freeze for Literal<A>
impl<A> RefUnwindSafe for Literal<A>
impl<A> !Send for Literal<A>
impl<A> !Sync for Literal<A>
impl<A> Unpin for Literal<A>
impl<A> UnwindSafe for Literal<A>
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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