pub struct ContractFile<'a> { /* private fields */ }Implementations§
Source§impl<'a> ContractFile<'a>
impl<'a> ContractFile<'a>
Sourcepub fn parse<CM>(
file_bytes: &'a [u8],
contract_method: CM,
) -> Result<Self, ContractFileParseError>
pub fn parse<CM>( file_bytes: &'a [u8], contract_method: CM, ) -> Result<Self, ContractFileParseError>
Parse file bytes and verify that internal invariants are valid.
contract_method argument is an optional callback called for each method in the contract
file with its method address in the contract memory, metadata item, and corresponding
metadata bytes. This can be used to collect available methods during parsing and avoid extra
iteration later using Self::iterate_methods() to compute MethodFingerprint, etc.
Sourcepub unsafe fn parse_unchecked(file_bytes: &'a [u8]) -> Self
pub unsafe fn parse_unchecked(file_bytes: &'a [u8]) -> Self
Similar to ContractFile::parse() but does not verify internal invariants and assumes the
input is valid.
This method is more efficient and does no checks that ContractFile::parse() does.
§Safety
Must be a valid input, for example, previously verified using ContractFile::parse().
Sourcepub fn header(&self) -> ContractFileHeader
pub fn header(&self) -> ContractFileHeader
Get file header
Sourcepub fn metadata_bytes(&self) -> &[u8] ⓘ
pub fn metadata_bytes(&self) -> &[u8] ⓘ
Metadata stored in the file
Sourcepub fn contract_memory_size(&self) -> u32
pub fn contract_memory_size(&self) -> u32
Memory allocation required for the contract
Sourcepub fn initialize_contract_memory(
&self,
contract_memory: &mut [MaybeUninit<u8>],
) -> bool
pub fn initialize_contract_memory( &self, contract_memory: &mut [MaybeUninit<u8>], ) -> bool
Initialize contract memory with file contents.
Use Self::contract_memory_size() to identify the exact necessary amount of memory.
Sourcepub fn iterate_methods(
&self,
) -> impl ExactSizeIterator<Item = ContractFileMethod<'_>> + TrustedLen
pub fn iterate_methods( &self, ) -> impl ExactSizeIterator<Item = ContractFileMethod<'_>> + TrustedLen
Iterate over all methods in the contract
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for ContractFile<'a>
impl<'a> RefUnwindSafe for ContractFile<'a>
impl<'a> Send for ContractFile<'a>
impl<'a> Sync for ContractFile<'a>
impl<'a> Unpin for ContractFile<'a>
impl<'a> UnwindSafe for ContractFile<'a>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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