pub struct LazyContext { /* private fields */ }Expand description
Pre-parsed header from the BPF input buffer: instruction data + program ID, plus a cursor positioned at the first account.
Accounts are parsed lazily as you call next_account().
Implementations§
Source§impl LazyContext
impl LazyContext
Sourcepub fn next_validated_signer(&mut self) -> Result<SignerView, ProgramError>
pub fn next_validated_signer(&mut self) -> Result<SignerView, ProgramError>
Parse the next account as a proven signer.
Sourcepub fn next_validated_writable(&mut self) -> Result<WritableView, ProgramError>
pub fn next_validated_writable(&mut self) -> Result<WritableView, ProgramError>
Parse the next account as a proven writable.
Sourcepub fn next_validated_mutable(&mut self) -> Result<MutableView, ProgramError>
pub fn next_validated_mutable(&mut self) -> Result<MutableView, ProgramError>
Parse the next account as a proven mutable (signer + writable).
Sourcepub fn next_validated_owned(
&mut self,
owner: &Address,
) -> Result<OwnedView, ProgramError>
pub fn next_validated_owned( &mut self, owner: &Address, ) -> Result<OwnedView, ProgramError>
Parse the next account as a proven program-owned account.
Sourcepub fn next_validated_executable(
&mut self,
) -> Result<ExecutableView, ProgramError>
pub fn next_validated_executable( &mut self, ) -> Result<ExecutableView, ProgramError>
Parse the next account as a proven executable program.
Source§impl LazyContext
impl LazyContext
Sourcepub fn instruction_data(&self) -> &[u8]
pub fn instruction_data(&self) -> &[u8]
Instruction data for this invocation.
Sourcepub fn program_id(&self) -> &Address
pub fn program_id(&self) -> &Address
The program ID of this invocation.
Sourcepub fn total_accounts(&self) -> usize
pub fn total_accounts(&self) -> usize
Number of accounts declared in the transaction.
Sourcepub fn parsed_count(&self) -> usize
pub fn parsed_count(&self) -> usize
Number of accounts parsed so far.
Sourcepub fn next_account(&mut self) -> Result<AccountView, ProgramError>
pub fn next_account(&mut self) -> Result<AccountView, ProgramError>
Parse and return the next account from the input buffer.
Each call advances the internal cursor by one account. Returns
Err(NotEnoughAccountKeys) if all accounts have been consumed.
Sourcepub fn next_signer(&mut self) -> Result<AccountView, ProgramError>
pub fn next_signer(&mut self) -> Result<AccountView, ProgramError>
Parse the next account and validate it is a signer.
Sourcepub fn next_writable(&mut self) -> Result<AccountView, ProgramError>
pub fn next_writable(&mut self) -> Result<AccountView, ProgramError>
Parse the next account and validate it is writable.
Sourcepub fn next_payer(&mut self) -> Result<AccountView, ProgramError>
pub fn next_payer(&mut self) -> Result<AccountView, ProgramError>
Parse the next account and validate it is a writable signer (payer).
Sourcepub fn next_owned_by(
&mut self,
program: &Address,
) -> Result<AccountView, ProgramError>
pub fn next_owned_by( &mut self, program: &Address, ) -> Result<AccountView, ProgramError>
Parse the next account and validate it is owned by program.
Sourcepub fn skip(&mut self, n: usize) -> Result<(), ProgramError>
pub fn skip(&mut self, n: usize) -> Result<(), ProgramError>
Skip n accounts without returning them.
Advances the cursor through the raw buffer without constructing full AccountView values, only doing enough work to find account boundaries.
Sourcepub fn drain_remaining(&mut self) -> Result<&[AccountView], ProgramError>
pub fn drain_remaining(&mut self) -> Result<&[AccountView], ProgramError>
Collect all remaining accounts into a slice of the internal buffer.
Parses all remaining accounts eagerly and returns them as a slice.
After this call, remaining() returns 0.
Sourcepub fn get(&self, index: usize) -> Option<&AccountView>
pub fn get(&self, index: usize) -> Option<&AccountView>
Get an already-parsed account by index.
Returns None if index >= parsed_count.