Skip to main content

LazyContext

Struct LazyContext 

Source
pub struct LazyContext<'a, 'info> { /* private fields */ }
Expand description

Runtime-typed view over a native lazy parsing context.

Construction happens inside the runtime’s hopper_lazy_entrypoint! expansion (LazyContext::from_native); handlers only ever see this wrapper. Every method delegates to the substrate implementation and converts at the boundary without re-parsing or copying account data.

Implementations§

Source§

impl<'a, 'info> LazyContext<'a, 'info>

Source

pub fn from_native(inner: &'a mut LazyContext<'info>) -> Self

Wrap a substrate lazy context. Called by the runtime’s hopper_lazy_entrypoint! expansion; public so custom entrypoint plumbing can bridge the same way.

Source

pub fn instruction_data(&self) -> &[u8]

Instruction data for this invocation. Available at any time, including before any account is consumed.

Source

pub fn program_id(&self) -> &Address

The executing program’s id.

Source

pub fn total_accounts(&self) -> usize

Total accounts the instruction declared.

Source

pub fn parsed_count(&self) -> usize

How many accounts have been parsed so far.

Source

pub fn remaining(&self) -> usize

How many declared accounts remain unparsed.

Source

pub fn next_account(&mut self) -> Result<AccountView<'info>, ProgramError>

Parse and return the next account.

Source

pub fn next_signer(&mut self) -> Result<AccountView<'info>, ProgramError>

Parse the next account and require it to be a signer.

Source

pub fn next_writable(&mut self) -> Result<AccountView<'info>, ProgramError>

Parse the next account and require it to be writable.

Source

pub fn next_payer(&mut self) -> Result<AccountView<'info>, ProgramError>

Parse the next account and require signer + writable (a fee payer shape).

Source

pub fn next_owned_by( &mut self, program: &Address, ) -> Result<AccountView<'info>, ProgramError>

Parse the next account and require its owner to be program.

Source

pub fn skip(&mut self, n: usize) -> Result<(), ProgramError>

Skip the next n accounts without exposing them.

Source

pub fn drain_remaining(&mut self) -> Result<&[AccountView<'info>], ProgramError>

Parse every remaining account and return them as a slice.

Source

pub fn get(&self, index: usize) -> Option<&AccountView<'info>>

Already-parsed account at index, if it has been consumed.

Auto Trait Implementations§

§

impl<'a, 'info> !RefUnwindSafe for LazyContext<'a, 'info>

§

impl<'a, 'info> !Send for LazyContext<'a, 'info>

§

impl<'a, 'info> !Sync for LazyContext<'a, 'info>

§

impl<'a, 'info> !UnwindSafe for LazyContext<'a, 'info>

§

impl<'a, 'info> Freeze for LazyContext<'a, 'info>

§

impl<'a, 'info> Unpin for LazyContext<'a, 'info>

§

impl<'a, 'info> UnsafeUnpin for LazyContext<'a, 'info>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.