Struct miden_processor::Digest

source ·
pub struct Digest(/* private fields */);

Implementations§

source§

impl RpoDigest

source

pub const fn new(value: [BaseElement; 4]) -> RpoDigest

source

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

source

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

source

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

source

pub fn to_hex(&self) -> String

Returns hexadecimal representation of this digest prefixed with 0x.

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

1.57.0 · source

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

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

1.77.0 · source

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

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

§Example
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.

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<(), Error>

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) -> &<RpoDigest as Deref>::Target

Dereferences the value.
source§

impl Deserializable for RpoDigest

source§

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

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§

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<(), Error>

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

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

source§

fn from(value: &[BaseElement; 4]) -> RpoDigest

Converts to this type from the input type.
source§

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

source§

fn from(value: &RpoDigest) -> [BaseElement; 4]

Converts to this type from the input type.
source§

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

source§

fn from(value: &RpoDigest) -> [u64; 4]

Converts to this type from the input type.
source§

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

source§

fn from(value: &RpoDigest) -> [u8; 32]

Converts to this type from the input type.
source§

impl From<[BaseElement; 4]> for RpoDigest

source§

fn from(value: [BaseElement; 4]) -> RpoDigest

Converts to this type from the input type.
source§

impl From<RpoDigest> for [BaseElement; 4]

source§

fn from(value: RpoDigest) -> [BaseElement; 4]

Converts to this type from the input type.
source§

impl From<RpoDigest> for [u64; 4]

source§

fn from(value: RpoDigest) -> [u64; 4]

Converts to this type from the input type.
source§

impl From<RpoDigest> for [u8; 32]

source§

fn from(value: RpoDigest) -> [u8; 32]

Converts to this type from the input type.
source§

impl FromIterator<RpoDigest> for MerklePath

source§

fn from_iter<T>(iter: T) -> MerklePath
where T: IntoIterator<Item = RpoDigest>,

Creates a value from an iterator. Read more
source§

impl IntoIterator for RpoDigest

§

type Item = BaseElement

The type of the elements being iterated over.
§

type IntoIter = <[BaseElement; 4] as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <RpoDigest as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl Ord for RpoDigest

source§

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

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

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

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

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

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

fn clamp(self, min: Self, max: Self) -> Self
where 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: &RpoDigest) -> 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<RpoDigest>

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

impl Serializable for RpoDigest

source§

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

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 get_size_hint(&self) -> usize

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

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

§

type Error = RpoDigestError

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

fn try_from(value: &[u64; 4]) -> Result<RpoDigest, RpoDigestError>

Performs the conversion.
source§

impl TryFrom<&[u8]> for RpoDigest

§

type Error = HexParseError

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

fn try_from( value: &[u8] ) -> Result<RpoDigest, <RpoDigest as TryFrom<&[u8]>>::Error>

Performs the conversion.
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<RpoDigest, <RpoDigest as TryFrom<&[u8; 32]>>::Error>

Performs the conversion.
source§

impl TryFrom<&String> for RpoDigest

source§

fn try_from( value: &String ) -> Result<RpoDigest, <RpoDigest as TryFrom<&String>>::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<RpoDigest, <RpoDigest as TryFrom<&str>>::Error>

Expects the string to start with 0x.

§

type Error = HexParseError

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

impl TryFrom<[u64; 4]> for RpoDigest

§

type Error = RpoDigestError

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

fn try_from(value: [u64; 4]) -> Result<RpoDigest, RpoDigestError>

Performs the conversion.
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<RpoDigest, <RpoDigest as TryFrom<[u8; 32]>>::Error>

Performs the conversion.
source§

impl TryFrom<String> for RpoDigest

source§

fn try_from( value: String ) -> Result<RpoDigest, <RpoDigest as TryFrom<String>>::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 StructuralPartialEq for RpoDigest

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where 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 T
where 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 T
where 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 T
where 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 T
where 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more