Skip to main content

RemainingAccounts

Struct RemainingAccounts 

Source
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>

Source

pub fn strict( declared: &'a [AccountView<'a>], remaining: &'a [AccountView<'a>], ) -> Self

Build a strict accessor. Iteration rejects duplicates.

Source

pub fn passthrough( declared: &'a [AccountView<'a>], remaining: &'a [AccountView<'a>], ) -> Self

Build a passthrough accessor. Iteration preserves duplicates.

Source

pub fn len(&self) -> usize

Length of the remaining slice, irrespective of mode.

Source

pub fn is_empty(&self) -> bool

True when there are no remaining accounts.

Source

pub fn mode(&self) -> RemainingMode

The active duplicate-handling policy for this view.

Source

pub fn as_slice(&self) -> &'a [AccountView<'a>]

The raw remaining-account slice backing this view.

Source

pub fn get( &self, index: usize, ) -> Result<Option<&'a AccountView<'a>>, 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).

Source

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.

Source

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.

Source

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.

Source

pub fn typed(&self) -> RemainingTyped<'a>

Sequential typed parser over the remaining-account tail.

This preserves the current duplicate policy while letting handlers bind each slot as a signer, raw account, or known external account in the order protocol instructions naturally expect.

Source

pub fn lazy(&self) -> RemainingLazy<'a>

Random-access lazy parser over the remaining-account tail.

This is useful when an instruction receives many optional accounts but validates only the branch it actually touches. The selected slot still inherits this view’s duplicate policy.

Auto Trait Implementations§

§

impl<'a> !Send for RemainingAccounts<'a>

§

impl<'a> !Sync for RemainingAccounts<'a>

§

impl<'a> Freeze for RemainingAccounts<'a>

§

impl<'a> RefUnwindSafe for RemainingAccounts<'a>

§

impl<'a> Unpin for RemainingAccounts<'a>

§

impl<'a> UnsafeUnpin for RemainingAccounts<'a>

§

impl<'a> UnwindSafe for RemainingAccounts<'a>

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.