pub struct InitAccount<'info, T: LayoutContract> { /* private fields */ }Expand description
Account that is expected to be created during this instruction.
InitAccount<'info, T> skips the layout-header check at validation
time (there’s nothing to validate yet. the CPI hasn’t run) but
otherwise behaves like Account<'info, T>. The #[hopper::context]
macro pairs it with #[account(init, payer = ..., space = ...)]
to emit the init_{field}() lifecycle helper that actually
performs the System Program CPI.
Implementations§
Source§impl<'info, T: LayoutContract> InitAccount<'info, T>
impl<'info, T: LayoutContract> InitAccount<'info, T>
Sourcepub unsafe fn new_unchecked(view: &'info AccountView) -> Self
pub unsafe fn new_unchecked(view: &'info AccountView) -> Self
Wrap an AccountView slot that will be created + initialised
by a lifecycle helper later in this instruction. Unsafe
because no state invariants hold for the account at wrap time.
Sourcepub fn as_account(&self) -> &'info AccountView
pub fn as_account(&self) -> &'info AccountView
The underlying account view.
Sourcepub fn load_after_init(&self) -> Result<RefMut<'_, T>, ProgramError>
pub fn load_after_init(&self) -> Result<RefMut<'_, T>, ProgramError>
After init_{field}() has run, load the freshly-initialised
layout for reads / writes. The caller is responsible for
ordering this after the lifecycle helper.