pub struct Value { /* private fields */ }Expand description
A Simplicity value.
Implementations§
Source§impl Value
impl Value
Sourcepub fn shallow_clone(&self) -> Self
pub fn shallow_clone(&self) -> Self
Make a cheap copy of the value.
Sourcepub fn left(inner: Self, right: Arc<Final>) -> Self
pub fn left(inner: Self, right: Arc<Final>) -> Self
Create a left value that wraps the given inner value.
Sourcepub fn right(left: Arc<Final>, inner: Self) -> Self
pub fn right(left: Arc<Final>, inner: Self) -> Self
Create a right value that wraps the given inner value.
Sourcepub fn product(left: Self, right: Self) -> Self
pub fn product(left: Self, right: Self) -> Self
Create a product value that wraps the given left and right values.
Sourcepub fn compact_len(&self) -> usize
pub fn compact_len(&self) -> usize
Return the bit length of the value in compact encoding.
Sourcepub fn padded_len(&self) -> usize
pub fn padded_len(&self) -> usize
Return the bit length of the value in padded encoding.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Check if the value is a nested product of units. In this case, the value contains no information.
Sourcepub fn as_product(&self) -> Option<(ValueRef<'_>, ValueRef<'_>)>
pub fn as_product(&self) -> Option<(ValueRef<'_>, ValueRef<'_>)>
Access the inner values of a product value.
Sourcepub fn from_byte_array<const N: usize>(bytes: [u8; N]) -> Self
pub fn from_byte_array<const N: usize>(bytes: [u8; N]) -> Self
Sourcepub fn raw_byte_iter(&self) -> RawByteIter<'_>
pub fn raw_byte_iter(&self) -> RawByteIter<'_>
Yields an iterator over the “raw bytes” of the value.
The returned bytes match the padded bit-encoding of the value. You
may wish to call Self::iter_padded instead to obtain the bits,
but this method is more efficient in some contexts.
Sourcepub fn iter_compact(&self) -> CompactBitsIter<'_>
pub fn iter_compact(&self) -> CompactBitsIter<'_>
Return an iterator over the compact bit encoding of the value.
This encoding is used for writing witness data and for computing IHRs.
Sourcepub fn iter_padded(&self) -> PreOrderIter<'_>
pub fn iter_padded(&self) -> PreOrderIter<'_>
Return an iterator over the padded bit encoding of the value.
This encoding is used to represent the value in the Bit Machine.
Sourcepub fn is_of_type(&self, ty: &Final) -> bool
pub fn is_of_type(&self, ty: &Final) -> bool
Check if the value is of the given type.
Sourcepub fn zero(ty: &Final) -> Self
pub fn zero(ty: &Final) -> Self
Get the zero value for the given type.
The zero value serializes to a string of zeroes.
§Construction
zero( 1 )=()zero( A + B )=zero(A)zero( A × B )=zero(A) × zero(B)
Sourcepub fn to_word(&self) -> Option<Word>
pub fn to_word(&self) -> Option<Word>
Try to convert the value into a word.
The value is cheaply cloned.
Sourcepub fn prune(&self, pruned_ty: &Final) -> Option<Self>
pub fn prune(&self, pruned_ty: &Final) -> Option<Self>
Prune the value down to the given type.
The pruned type must be smaller than or equal to the current type of the value.
Otherwise, this method returns None.
§Smallness
T≤Tfor all typesT1≤Tfor all typesTA1 + B1≤A2 + B2ifA1≤A2andB1≤B2A1 × B1≤A2 × B2ifA1≤A2andB1≤B2
§Pruning
prune( v: T, 1 )=(): 1prune( L(l): A1 + B1, A2 + B2 )=prune(l: A1, A2) : A2 + B2prune( R(r): A1 + B1, A2 + B2 )=prune(r: B1, B2) : A2 + B2prune( (l, r): A1 × B1, A2 × B2 )=( prune(l: A1, A2), prune(r: B1, B2): A2 × B2
Source§impl Value
impl Value
Sourcepub fn from_compact_bits<I: Iterator<Item = u8>>(
bits: &mut BitIter<I>,
ty: &Final,
) -> Result<Self, EarlyEndOfStreamError>
pub fn from_compact_bits<I: Iterator<Item = u8>>( bits: &mut BitIter<I>, ty: &Final, ) -> Result<Self, EarlyEndOfStreamError>
Decode a value of the given type from its compact bit encoding.
Sourcepub fn from_padded_bits<I: Iterator<Item = u8>>(
bits: &mut BitIter<I>,
ty: &Final,
) -> Result<Self, EarlyEndOfStreamError>
pub fn from_padded_bits<I: Iterator<Item = u8>>( bits: &mut BitIter<I>, ty: &Final, ) -> Result<Self, EarlyEndOfStreamError>
Decode a value of the given type from its padded bit encoding.