Skip to main content

HopperCpi

Struct HopperCpi 

Source
pub struct HopperCpi<'a, const ACCTS: usize, const DATA: usize> { /* private fields */ }
Expand description

Stack-allocated CPI call with compile-time-known account count and data size.

Both ACCTS and DATA are const generics – the compiler knows the exact buffer sizes at compile time, enabling optimal stack allocation and no runtime branching on sizes.

Implementations§

Source§

impl<'a, const ACCTS: usize, const DATA: usize> HopperCpi<'a, ACCTS, DATA>

Source

pub fn new(program_id: &'a Address) -> Self

Begin building a CPI call to program_id.

Source

pub fn add_account( self, view: &'a AccountView, is_writable: bool, is_signer: bool, ) -> Self

Add an account to the CPI call.

Must be called exactly ACCTS times before invoke.

Source

pub fn set_data(self, src: &[u8; DATA]) -> Self

Set the instruction data. Must be exactly DATA bytes.

Source

pub fn set_data_from_slice(self, src: &[u8]) -> Result<Self, ProgramError>

Write instruction data from a slice (must be exactly DATA bytes).

Source

pub fn invoke(&self) -> ProgramResult

Invoke the CPI without signer seeds.

Source

pub fn invoke_signed(&self, seeds: &[&[&[u8]]]) -> ProgramResult

Invoke the CPI with PDA signer seeds.

Auto Trait Implementations§

§

impl<'a, const ACCTS: usize, const DATA: usize> Freeze for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> RefUnwindSafe for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> Send for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> Sync for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> Unpin for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> UnsafeUnpin for HopperCpi<'a, ACCTS, DATA>

§

impl<'a, const ACCTS: usize, const DATA: usize> UnwindSafe for HopperCpi<'a, ACCTS, DATA>

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.