Struct miden_client::accounts::AccountCode
source · pub struct AccountCode { /* private fields */ }Expand description
A public interface of an account.
Account’s public interface consists of a set of account procedures, each procedure being a Miden VM program. Thus, MAST root of each procedure commits to the underlying program. We commit to the entire account interface by building a simple Merkle tree out of all procedure MAST roots.
Implementations§
source§impl AccountCode
impl AccountCode
sourcepub const PROCEDURE_TREE_DEPTH: u8 = 8u8
pub const PROCEDURE_TREE_DEPTH: u8 = 8u8
The depth of the Merkle tree that is used to commit to the account’s public interface.
sourcepub const MAX_NUM_PROCEDURES: usize = 256usize
pub const MAX_NUM_PROCEDURES: usize = 256usize
The maximum number of account interface procedures.
sourcepub fn new(
module: ModuleAst,
assembler: &Assembler,
) -> Result<AccountCode, AccountError>
pub fn new( module: ModuleAst, assembler: &Assembler, ) -> Result<AccountCode, AccountError>
Returns a new definition of an account’s interface compiled from the specified source code.
§Errors
Returns an error if:
- Compilation of the provided module fails.
- The number of procedures exported from the provided module is smaller than 1 or greater than 256.
sourcepub fn from_parts(module: ModuleAst, procedures: Vec<RpoDigest>) -> AccountCode
pub fn from_parts(module: ModuleAst, procedures: Vec<RpoDigest>) -> AccountCode
Returns a new definition of an account’s interface instantiated from the provided module and list of procedure digests.
Note: this function assumes that the list of provided procedure digests results from the compilation of the provided module, but this is not checked.
§Panics
Panics if the number of procedures is smaller than 1 or greater than 256.
sourcepub fn module(&self) -> &ModuleAst
pub fn module(&self) -> &ModuleAst
Returns a reference to the ModuleAst backing the AccountCode.
sourcepub fn procedures(&self) -> &[RpoDigest]
pub fn procedures(&self) -> &[RpoDigest]
Returns a reference to the account procedure digests.
sourcepub fn procedure_tree(
&self,
) -> &SimpleSmt<miden_objects::::accounts::code::{impl#0}::procedure_tree::{constant#0}>
pub fn procedure_tree( &self, ) -> &SimpleSmt<miden_objects::::accounts::code::{impl#0}::procedure_tree::{constant#0}>
Returns a reference to the procedure tree.
sourcepub fn num_procedures(&self) -> usize
pub fn num_procedures(&self) -> usize
Returns the number of public interface procedures defined for this account.
sourcepub fn has_procedure(&self, root: RpoDigest) -> bool
pub fn has_procedure(&self, root: RpoDigest) -> bool
Returns true if a procedure with the specified root is defined for this account.
sourcepub fn get_procedure_by_index(&self, index: usize) -> RpoDigest
pub fn get_procedure_by_index(&self, index: usize) -> RpoDigest
Returns a procedure digest for the procedure with the specified index.
§Panics
Panics if the provided index is out of bounds.
sourcepub fn get_procedure_index_by_root(&self, root: RpoDigest) -> Option<usize>
pub fn get_procedure_index_by_root(&self, root: RpoDigest) -> Option<usize>
Returns the procedure index for the procedure with the specified root or None if such procedure is not defined for this account.
Trait Implementations§
source§impl Clone for AccountCode
impl Clone for AccountCode
source§fn clone(&self) -> AccountCode
fn clone(&self) -> AccountCode
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for AccountCode
impl Debug for AccountCode
source§impl Deserializable for AccountCode
impl Deserializable for AccountCode
source§fn read_from<R>(source: &mut R) -> Result<AccountCode, DeserializationError>where
R: ByteReader,
fn read_from<R>(source: &mut R) -> Result<AccountCode, 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 PartialEq for AccountCode
impl PartialEq for AccountCode
source§fn eq(&self, other: &AccountCode) -> bool
fn eq(&self, other: &AccountCode) -> bool
self and other values to be equal, and is used
by ==.source§impl Serializable for AccountCode
impl Serializable for AccountCode
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
impl Eq for AccountCode
Auto Trait Implementations§
impl Freeze for AccountCode
impl RefUnwindSafe for AccountCode
impl Send for AccountCode
impl Sync for AccountCode
impl Unpin for AccountCode
impl UnwindSafe for AccountCode
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)