pub fn invoke_and_read<T: Projectable, const ACCOUNTS: usize>(
instruction: &InstructionView<'_, '_, '_, '_>,
account_views: &[&AccountView<'_>; ACCOUNTS],
signers_seeds: &[Signer<'_, '_>],
) -> Result<ReturnData, ProgramError>Expand description
Invoke a CPI and capture a producer-checked, type-validated return snapshot.
The producing program must equal instruction.program_id. The snapshot
must contain an aligned T prefix; trailing bytes are permitted, matching
ReturnData::as_type. No data is InvalidAccountData, a different producer
is IncorrectProgramId, and a short result is AccountDataTooSmall.
Call as_type::<T>() on the returned snapshot to borrow the value.
ⓘ
let snapshot = invoke_and_read::<PriceData, 2>(&instruction, &accounts, &[])?;
let oracle_price = snapshot.as_type::<PriceData>()?;