pub struct Word(/* private fields */);Expand description
A unit of data consisting of 4 field elements.
Implementations§
Source§impl Word
impl Word
Sourcepub const SERIALIZED_SIZE: usize = 32usize
pub const SERIALIZED_SIZE: usize = 32usize
The serialized size of the word in bytes.
Sourcepub const fn new(value: [BaseElement; 4]) -> Word
pub const fn new(value: [BaseElement; 4]) -> Word
Creates a new Word from the given field elements.
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_crypto::{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) -> &[BaseElement]
pub fn as_elements(&self) -> &[BaseElement]
Returns the word as a slice of field elements.
Sourcepub fn words_as_elements(words: &[Word]) -> &[BaseElement]
pub fn words_as_elements(words: &[Word]) -> &[BaseElement]
Returns all elements of multiple words as a slice.
Sourcepub fn to_hex(&self) -> String
pub fn to_hex(&self) -> String
Returns hexadecimal representation of this word prefixed with 0x.
Sourcepub fn to_vec(&self) -> Vec<BaseElement>
pub fn to_vec(&self) -> Vec<BaseElement>
Returns internal elements of this word as a vector.
Trait Implementations§
Source§impl Deserializable for Word
impl Deserializable for Word
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 read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
Source§impl From<&NoteMetadata> for Word
impl From<&NoteMetadata> for Word
Source§fn from(metadata: &NoteMetadata) -> Self
fn from(metadata: &NoteMetadata) -> Self
Convert a NoteMetadata into a Word.
The produced layout of the word is documented on the NoteMetadata type.
Source§impl From<&TransactionId> for Word
impl From<&TransactionId> for Word
Source§fn from(id: &TransactionId) -> Self
fn from(id: &TransactionId) -> Self
Source§impl From<AssetVaultKey> for Word
impl From<AssetVaultKey> for Word
Source§fn from(vault_key: AssetVaultKey) -> Self
fn from(vault_key: AssetVaultKey) -> Self
Source§impl From<FungibleAsset> for Word
impl From<FungibleAsset> for Word
Source§fn from(asset: FungibleAsset) -> Self
fn from(asset: FungibleAsset) -> Self
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<NonFungibleAsset> for Word
impl From<NonFungibleAsset> for Word
Source§fn from(asset: NonFungibleAsset) -> Self
fn from(asset: NonFungibleAsset) -> Self
Source§impl From<NoteMetadata> for Word
impl From<NoteMetadata> for Word
Source§fn from(metadata: NoteMetadata) -> Self
fn from(metadata: NoteMetadata) -> Self
Convert a NoteMetadata into a Word.
The produced layout of the word is documented on the NoteMetadata type.
Source§impl From<PublicKeyCommitment> for Word
impl From<PublicKeyCommitment> for Word
Source§fn from(value: PublicKeyCommitment) -> Self
fn from(value: PublicKeyCommitment) -> Self
Source§impl From<TransactionId> for Word
impl From<TransactionId> for Word
Source§fn from(id: TransactionId) -> Self
fn from(id: TransactionId) -> Self
Source§impl From<Word> for LexicographicWord
impl From<Word> for LexicographicWord
Source§fn from(word: Word) -> LexicographicWord
fn from(word: Word) -> LexicographicWord
Source§impl From<Word> for PublicKeyCommitment
impl From<Word> for PublicKeyCommitment
Source§impl From<Word> for TransactionId
impl From<Word> for TransactionId
Source§impl FromIterator<Word> for MerklePath
impl FromIterator<Word> for MerklePath
Source§fn from_iter<T>(iter: T) -> MerklePathwhere
T: IntoIterator<Item = Word>,
fn from_iter<T>(iter: T) -> MerklePathwhere
T: IntoIterator<Item = Word>,
Source§impl IntoIterator for Word
impl IntoIterator for Word
Source§type Item = BaseElement
type Item = BaseElement
Source§type IntoIter = <[BaseElement; 4] as IntoIterator>::IntoIter
type IntoIter = <[BaseElement; 4] as IntoIterator>::IntoIter
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§impl Serializable for Word
impl Serializable for Word
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 TryFrom<&[BaseElement]> for Word
impl TryFrom<&[BaseElement]> for Word
Source§impl TryFrom<Word> for FungibleAsset
impl TryFrom<Word> for FungibleAsset
Source§impl TryFrom<Word> for NonFungibleAsset
impl TryFrom<Word> for NonFungibleAsset
Source§impl TryFrom<Word> for NoteMetadata
impl TryFrom<Word> for NoteMetadata
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 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 moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more