pub struct RemainingAccounts<'a> { /* private fields */ }Expand description
Zero-allocation remaining-accounts view.
Construct via RemainingAccounts::strict or
RemainingAccounts::passthrough from the declared slice and the
full accounts slice. #[hopper::context] emits
ctx.remaining_accounts() and ctx.remaining_accounts_passthrough()
accessors that wire these up for you.
Implementations§
Source§impl<'a> RemainingAccounts<'a>
impl<'a> RemainingAccounts<'a>
Sourcepub fn strict(declared: &'a [AccountView], remaining: &'a [AccountView]) -> Self
pub fn strict(declared: &'a [AccountView], remaining: &'a [AccountView]) -> Self
Build a strict accessor. Iteration rejects duplicates.
Sourcepub fn passthrough(
declared: &'a [AccountView],
remaining: &'a [AccountView],
) -> Self
pub fn passthrough( declared: &'a [AccountView], remaining: &'a [AccountView], ) -> Self
Build a passthrough accessor. Iteration preserves duplicates.
Sourcepub fn mode(&self) -> RemainingMode
pub fn mode(&self) -> RemainingMode
The active duplicate-handling policy for this view.
Sourcepub fn as_slice(&self) -> &'a [AccountView]
pub fn as_slice(&self) -> &'a [AccountView]
The raw remaining-account slice backing this view.
Sourcepub fn get(&self, index: usize) -> Result<Option<&'a AccountView>, ProgramError>
pub fn get(&self, index: usize) -> Result<Option<&'a AccountView>, ProgramError>
Random access by index. Passthrough returns the slot as is;
strict returns an error when the resolved slot aliases a
previously-seen account (declared or yielded before index).
Sourcepub fn account_views<const N: usize>(
&self,
) -> Result<RemainingAccountViews<'a, N>, ProgramError>
pub fn account_views<const N: usize>( &self, ) -> Result<RemainingAccountViews<'a, N>, ProgramError>
Validate the remaining tail as at most N account views.
In strict mode this also rejects aliases to declared accounts and duplicate remaining slots before returning the typed set.
Sourcepub fn signers<const N: usize>(
&self,
) -> Result<RemainingSigners<'a, N>, ProgramError>
pub fn signers<const N: usize>( &self, ) -> Result<RemainingSigners<'a, N>, ProgramError>
Validate the remaining tail as at most N signer accounts.
This is the common multisig case: the handler gets a bounded, duplicate-safe signer set instead of raw account iteration.
Sourcepub fn iter(&self) -> RemainingIter<'a> ⓘ
pub fn iter(&self) -> RemainingIter<'a> ⓘ
Sequential iterator. Yields each account in declaration order, errors on duplicates in strict mode, preserves them in passthrough mode.