pub struct RpoDigest(/* private fields */);

Implementations§

source§

impl RpoDigest

source

pub const fn new(value: [Felt; 4]) -> Self

source

pub fn as_elements(&self) -> &[Felt]

source

pub fn as_bytes(&self) -> [u8; 32]

source

pub fn digests_as_elements<'a, I>(digests: I) -> impl Iterator<Item = &'a Felt>where I: Iterator<Item = &'a Self>,

Methods from Deref<Target = [Felt; 4]>§

1.57.0 · source

pub fn as_slice(&self) -> &[T]

Returns a slice containing the entire array. Equivalent to &s[..].

source

pub fn each_ref(&self) -> [&T; N]

🔬This is a nightly-only experimental API. (array_methods)

Borrows each element and returns an array of references with the same size as self.

Example
#![feature(array_methods)]

let floats = [3.1, 2.7, -1.0];
let float_refs: [&f64; 3] = floats.each_ref();
assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);

This method is particularly useful if combined with other methods, like map. This way, you can avoid moving the original array if its elements are not Copy.

#![feature(array_methods)]

let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()];
let is_ascii = strings.each_ref().map(|s| s.is_ascii());
assert_eq!(is_ascii, [true, false, true]);

// We can still access the original array: it has not been moved.
assert_eq!(strings.len(), 3);
source

pub fn split_array_ref<const M: usize>(&self) -> (&[T; M], &[T])

🔬This is a nightly-only experimental API. (split_array)

Divides one array reference into two at an index.

The first will contain all indices from [0, M) (excluding the index M itself) and the second will contain all indices from [M, N) (excluding the index N itself).

Panics

Panics if M > N.

Examples
#![feature(split_array)]

let v = [1, 2, 3, 4, 5, 6];

{
   let (left, right) = v.split_array_ref::<0>();
   assert_eq!(left, &[]);
   assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}

{
    let (left, right) = v.split_array_ref::<2>();
    assert_eq!(left, &[1, 2]);
    assert_eq!(right, &[3, 4, 5, 6]);
}

{
    let (left, right) = v.split_array_ref::<6>();
    assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
    assert_eq!(right, &[]);
}
source

pub fn rsplit_array_ref<const M: usize>(&self) -> (&[T], &[T; M])

🔬This is a nightly-only experimental API. (split_array)

Divides one array reference into two at an index from the end.

The first will contain all indices from [0, N - M) (excluding the index N - M itself) and the second will contain all indices from [N - M, N) (excluding the index N itself).

Panics

Panics if M > N.

Examples
#![feature(split_array)]

let v = [1, 2, 3, 4, 5, 6];

{
   let (left, right) = v.rsplit_array_ref::<0>();
   assert_eq!(left, &[1, 2, 3, 4, 5, 6]);
   assert_eq!(right, &[]);
}

{
    let (left, right) = v.rsplit_array_ref::<2>();
    assert_eq!(left, &[1, 2, 3, 4]);
    assert_eq!(right, &[5, 6]);
}

{
    let (left, right) = v.rsplit_array_ref::<6>();
    assert_eq!(left, &[]);
    assert_eq!(right, &[1, 2, 3, 4, 5, 6]);
}
source

pub fn as_ascii(&self) -> Option<&[AsciiChar; N]>

🔬This is a nightly-only experimental API. (ascii_char)

Converts this array of bytes into a array of ASCII characters, or returns None if any of the characters is non-ASCII.

Examples
#![feature(ascii_char)]
#![feature(const_option)]

const HEX_DIGITS: [std::ascii::Char; 16] =
    *b"0123456789abcdef".as_ascii().unwrap();

assert_eq!(HEX_DIGITS[1].as_str(), "1");
assert_eq!(HEX_DIGITS[10].as_str(), "a");
source

pub unsafe fn as_ascii_unchecked(&self) -> &[AsciiChar; N]

🔬This is a nightly-only experimental API. (ascii_char)

Converts this array of bytes into a array of ASCII characters, without checking whether they’re valid.

Safety

Every byte in the array must be in 0..=127, or else this is UB.

Trait Implementations§

source§

impl Clone for RpoDigest

source§

fn clone(&self) -> RpoDigest

Returns a copy 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 RpoDigest

source§

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

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

impl Default for RpoDigest

source§

fn default() -> RpoDigest

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

impl Deref for RpoDigest

§

type Target = [BaseElement; 4]

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Deserializable for RpoDigest

source§

fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into Self, and returns the result. Read more
source§

fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>

Attempts to deserialize the provided bytes into Self and returns the result. Read more
source§

fn read_batch_from<R>( source: &mut R, num_elements: usize ) -> Result<Vec<Self>, DeserializationError>where R: ByteReader,

Reads a sequence of bytes from the provided source, attempts to deserialize these bytes into a vector with the specified number of Self elements, and returns the result. Read more
source§

impl Digest for RpoDigest

source§

fn as_bytes(&self) -> [u8; 32]

Returns this digest serialized into an array of bytes. Read more
source§

impl Display for RpoDigest

source§

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

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

impl From<&RpoDigest> for [Felt; 4]

source§

fn from(value: &RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<&RpoDigest> for [u64; 4]

source§

fn from(value: &RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<&RpoDigest> for [u8; 32]

source§

fn from(value: &RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<&RpoDigest> for String

source§

fn from(value: &RpoDigest) -> Self

The returned string starts with 0x.

source§

impl From<[BaseElement; 4]> for RpoDigest

source§

fn from(value: [Felt; 4]) -> Self

Converts to this type from the input type.
source§

impl From<RpoDigest> for [Felt; 4]

source§

fn from(value: RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<RpoDigest> for [u64; 4]

source§

fn from(value: RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<RpoDigest> for [u8; 32]

source§

fn from(value: RpoDigest) -> Self

Converts to this type from the input type.
source§

impl From<RpoDigest> for String

source§

fn from(value: RpoDigest) -> Self

The returned string starts with 0x.

source§

impl FromIterator<RpoDigest> for MerklePath

source§

fn from_iter<T: IntoIterator<Item = RpoDigest>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl Ord for RpoDigest

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for RpoDigest

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for RpoDigest

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Randomizable for RpoDigest

source§

const VALUE_SIZE: usize = 32usize

Size of Self in bytes. Read more
source§

fn from_random_bytes(bytes: &[u8]) -> Option<Self>

Returns Self if the set of bytes forms a valid value, otherwise returns None.
source§

impl Serializable for RpoDigest

source§

fn write_into<W: ByteWriter>(&self, target: &mut W)

Serializes self into bytes and writes these bytes into the target.
source§

fn to_bytes(&self) -> Vec<u8>

Serializes self into a vector of bytes.
source§

fn write_batch_into<W>(source: &[Self], target: &mut W)where W: ByteWriter,

Serializes all elements of the source and writes these bytes into the target. Read more
source§

fn get_size_hint(&self) -> usize

Returns an estimate of how many bytes are needed to represent self. Read more
source§

impl<T: KvMap<RpoDigest, StoreNode>> TryApplyDiff<RpoDigest, StoreNode> for MerkleStore<T>

§

type Error = MerkleError

An error type that can be returned if the changes cannot be applied.
§

type DiffType = MerkleStoreDelta

The type that describes the difference between two objects.
source§

fn try_apply(&mut self, diff: Self::DiffType) -> Result<(), MerkleError>

Applies the provided changes described by Self::DiffType to the object implementing this trait. Returns an error if the changes cannot be applied.
source§

impl TryApplyDiff<RpoDigest, StoreNode> for SimpleSmt

§

type Error = MerkleError

An error type that can be returned if the changes cannot be applied.
§

type DiffType = MerkleTreeDelta

The type that describes the difference between two objects.
source§

fn try_apply(&mut self, diff: MerkleTreeDelta) -> Result<(), MerkleError>

Applies the provided changes described by Self::DiffType to the object implementing this trait. Returns an error if the changes cannot be applied.
source§

impl TryFrom<&String> for RpoDigest

source§

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

Expects the string to start with 0x.

§

type Error = HexParseError

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

impl TryFrom<&str> for RpoDigest

source§

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

Expects the string to start with 0x.

§

type Error = HexParseError

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

impl TryFrom<[u8; 32]> for RpoDigest

§

type Error = HexParseError

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

fn try_from(value: [u8; 32]) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl TryFrom<String> for RpoDigest

source§

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

Expects the string to start with 0x.

§

type Error = HexParseError

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

impl Copy for RpoDigest

source§

impl Eq for RpoDigest

source§

impl StructuralEq for RpoDigest

source§

impl StructuralPartialEq for RpoDigest

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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
source§

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

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.