#[repr(C)]pub struct Word {
pub a: Felt,
pub b: Felt,
pub c: Felt,
pub d: Felt,
}Expand description
A unit of data consisting of 4 field elements.
For ordering a word with Ord the word’s elements are treated as limbs of an integer
in little-endian limb order and thus comparison starts from the most significant element.
Fields§
§a: FeltThe underlying elements of this word.
b: Felt§c: Felt§d: FeltImplementations§
Source§impl Word
impl Word
Sourcepub const SERIALIZED_SIZE: usize = WORD_SIZE_BYTES
pub const SERIALIZED_SIZE: usize = WORD_SIZE_BYTES
The serialized size of the word in bytes.
Sourcepub const fn into_elements(self) -> [Felt; 4]
pub const fn into_elements(self) -> [Felt; 4]
Returns the elements of this word as an array.
Sourcepub const fn parse(hex: &str) -> Result<Word, &'static str>
pub const fn parse(hex: &str) -> Result<Word, &'static str>
Parses a hex string into a new Word.
The input must contain valid hex prefixed with 0x. The input after the prefix
must contain between 0 and 64 characters (inclusive).
The input is interpreted to have little-endian byte ordering. Nibbles are interpreted to have big-endian ordering so that “0x10” represents Felt::new(16), not Felt::new(1).
This function is usually used via the word! macro.
use miden_field::{Felt, Word, word};
let word = word!("0x1000000000000000200000000000000030000000000000004000000000000000");
assert_eq!(word, Word::new([Felt::new(16), Felt::new(32), Felt::new(48), Felt::new(64)]));Sourcepub fn as_elements(&self) -> &[Felt]
pub fn as_elements(&self) -> &[Felt]
Returns the word as a slice of field elements.
Sourcepub fn words_as_elements_iter<'a, I>(words: I) -> impl Iterator<Item = &'a Felt>
pub fn words_as_elements_iter<'a, I>(words: I) -> impl Iterator<Item = &'a Felt>
Returns an iterator over the elements of multiple words.
Sourcepub fn words_as_elements(words: &[Word]) -> &[Felt]
pub fn words_as_elements(words: &[Word]) -> &[Felt]
Returns all elements of multiple words as a slice.
Trait Implementations§
Source§impl Deserializable for Word
Available on not (target_family=wasm and miden).
impl Deserializable for Word
target_family=wasm and miden).Source§fn read_from<R>(source: &mut R) -> Result<Word, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<Word, DeserializationError>where
R: ByteReader,
source, attempts to deserialize these bytes
into Self, and returns the result. Read moreSource§fn min_serialized_size() -> usize
fn min_serialized_size() -> usize
Source§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§fn read_from_bytes_with_budget(
bytes: &[u8],
budget: usize,
) -> Result<Self, DeserializationError>
fn read_from_bytes_with_budget( bytes: &[u8], budget: usize, ) -> Result<Self, DeserializationError>
Self from bytes with a byte budget limit. Read moreSource§impl<'de> Deserialize<'de> for Word
impl<'de> Deserialize<'de> for Word
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Word, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Word, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<T> From<LexicographicWord<T>> for Word
impl<T> From<LexicographicWord<T>> for Word
Source§fn from(key: LexicographicWord<T>) -> Word
fn from(key: LexicographicWord<T>) -> Word
Source§impl From<Word> for LexicographicWord
impl From<Word> for LexicographicWord
Source§fn from(word: Word) -> LexicographicWord
fn from(word: Word) -> LexicographicWord
Source§impl FromIterator<Word> for MerklePath
impl FromIterator<Word> for MerklePath
Source§impl IntoIterator for Word
impl IntoIterator for Word
Source§impl Ord for Word
impl Ord for Word
Source§impl PartialOrd for Word
impl PartialOrd for Word
Source§impl Randomizable for Word
impl Randomizable for Word
Source§const VALUE_SIZE: usize = WORD_SIZE_BYTES
const VALUE_SIZE: usize = WORD_SIZE_BYTES
Self in bytes. Read moreSource§fn from_random_bytes(bytes: &[u8]) -> Option<Self>
fn from_random_bytes(bytes: &[u8]) -> Option<Self>
Self if the set of bytes forms a valid value, otherwise returns None.Source§impl Serializable for Word
Available on not (target_family=wasm and miden).
impl Serializable for Word
target_family=wasm and miden).Source§fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
fn write_into<W>(&self, target: &mut W)where
W: ByteWriter,
self into bytes and writes these bytes into the target.Source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Source§impl Serialize for Word
impl Serialize for Word
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Word
impl Eq for Word
impl StructuralPartialEq for Word
Auto Trait Implementations§
impl Freeze for Word
impl RefUnwindSafe for Word
impl Send for Word
impl Sync for Word
impl Unpin for Word
impl UnsafeUnpin for Word
impl UnwindSafe for Word
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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