Struct miden_objects::notes::NoteTag
source · pub struct NoteTag(/* private fields */);Implementations§
source§impl NoteTag
impl NoteTag
sourcepub fn from_account_id(
account_id: AccountId,
execution: NoteExecutionMode
) -> Result<Self, NoteError>
pub fn from_account_id( account_id: AccountId, execution: NoteExecutionMode ) -> Result<Self, NoteError>
Returns a new NoteTag instantiated from the specified account ID.
The tag is constructed as follows:
- For local execution, the two most significant bits are set to 0b00, the following 16 bits are set to the 16 most significant bits of the account ID, and the remaining 14 bits are set to 0.
- For network execution, the two most significant bits are set to 0b10 and the remaining bits are set to the 30 most significant bits of the account ID.
sourcepub fn is_single_target(&self) -> bool
pub fn is_single_target(&self) -> bool
Returns true if the note is intended for execution by a specific account.
A note is intended for execution by a single account if either the first two bits are zeros or the first 3 bits are 0b100.
sourcepub fn execution_mode(&self) -> NoteExecutionMode
pub fn execution_mode(&self) -> NoteExecutionMode
Returns note execution mode defined by this tag.
If the most significant bit of the tag is 0 or the 3 most significant bits are equal to 0b101, the note is intended for local execution; otherwise, the note is intended for network execution.
sourcepub fn validate(&self, note_type: NoteType) -> Result<Self, NoteError>
pub fn validate(&self, note_type: NoteType) -> Result<Self, NoteError>
Returns an error if this tag is not consistent with the specified note type, and self otherwise.
The tag and the note type are consistent if they satisfy the following rules:
- For off-chain notes, the most significant bit of the tag is 0.
- For public notes, the second most significant bit of the tag is 0.
- For encrypted notes, two most significant bits of the tag is 00.
Trait Implementations§
source§impl Deserializable for NoteTag
impl Deserializable for NoteTag
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
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 moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl PartialEq for NoteTag
impl PartialEq for NoteTag
source§impl Serializable for NoteTag
impl Serializable for NoteTag
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
source§impl TryFrom<BaseElement> for NoteTag
impl TryFrom<BaseElement> for NoteTag
impl Copy for NoteTag
impl Eq for NoteTag
impl StructuralPartialEq for NoteTag
Auto Trait Implementations§
impl Freeze for NoteTag
impl RefUnwindSafe for NoteTag
impl Send for NoteTag
impl Sync for NoteTag
impl Unpin for NoteTag
impl UnwindSafe for NoteTag
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
Mutably borrows from an owned value. Read more