Skip to main content

TokenBatch

Struct TokenBatch 

Source
pub struct TokenBatch<'a, const DATA: usize = 256, const ACCOUNTS: usize = 16> { /* private fields */ }
Expand description

A stack-resident batch of token instructions.

DATA bounds the instruction data (one discriminator byte plus the headers and data of every pushed instruction) and ACCOUNTS bounds the account list. A push that would overflow either is refused with InvalidArgument and leaves the batch unchanged.

Implementations§

Source§

impl<'a, const DATA: usize, const ACCOUNTS: usize> TokenBatch<'a, DATA, ACCOUNTS>

Source

pub const fn new() -> Self

An empty batch. DATA must hold at least the discriminator.

Source

pub fn push(&mut self, instruction: &impl TokenInstruction<'a>) -> ProgramResult

Append an instruction whose authority signs directly or through PDA seeds given at invoke time.

Source

pub fn push_multisig( &mut self, instruction: &impl TokenInstruction<'a>, multisig_signers: &[&'a AccountView<'a>], ) -> ProgramResult

Append an instruction whose authority is a multisig with these signer accounts.

Source

pub const fn len(&self) -> usize

How many instructions were pushed.

Source

pub const fn is_empty(&self) -> bool

Whether nothing was pushed yet.

Source

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

The instruction data as it will be sent: [255] then the headers and inner data.

Source

pub fn account_metas(&self) -> &[InstructionAccount<'a>]

The account metas as they will be sent.

Source

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

The account views as they will be sent, in meta order.

Source

pub fn invoke(&self) -> ProgramResult

Send the batch to SPL Token.

Source

pub fn invoke_signed(&self, signers: &[Signer<'_, '_>]) -> ProgramResult

Send the batch to SPL Token with PDA signers.

Source

pub fn invoke_on( &self, program: TokenProgram, signers: &[Signer<'_, '_>], ) -> ProgramResult

Send the batch to an explicit token program. An empty batch is refused with InvalidArgument rather than sent.

Trait Implementations§

Source§

impl<'a, const DATA: usize, const ACCOUNTS: usize> Default for TokenBatch<'a, DATA, ACCOUNTS>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, const DATA: usize, const ACCOUNTS: usize> TokenSink<'a> for TokenBatch<'a, DATA, ACCOUNTS>

Source§

fn emit<const N: usize>( &mut self, data: &[u8], accounts: [InstructionAccount<'a>; N], views: [&'a AccountView<'a>; N], trailing: &[Trailing<'_, 'a>], ) -> ProgramResult

Receive one encoded instruction: its data, its fixed account metas and views in order, and zero or more trailing runs appended after them.

Auto Trait Implementations§

§

impl<'a, const DATA: usize = 256, const ACCOUNTS: usize = 16> !Send for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize = 256, const ACCOUNTS: usize = 16> !Sync for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize, const ACCOUNTS: usize> Freeze for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize, const ACCOUNTS: usize> RefUnwindSafe for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize, const ACCOUNTS: usize> Unpin for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize, const ACCOUNTS: usize> UnsafeUnpin for TokenBatch<'a, DATA, ACCOUNTS>

§

impl<'a, const DATA: usize, const ACCOUNTS: usize> UnwindSafe for TokenBatch<'a, DATA, ACCOUNTS>

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.