pub struct Context<'info, T: Bumps> {
pub program_id: &'info Pubkey,
pub accounts: &'info mut T,
pub remaining_accounts: &'info [AccountInfo<'info>],
pub bumps: T::Bumps,
}Expand description
Provides non-argument inputs to the program.
§Example
ⓘ
pub fn set_data(ctx: Context<SetData>, age: u64, other_data: u32) -> Result<()> {
// Set account data like this
(*ctx.accounts.my_account).age = age;
(*ctx.accounts.my_account).other_data = other_data;
// or like this
let my_account = &mut ctx.account.my_account;
my_account.age = age;
my_account.other_data = other_data;
Ok(())
}Fields§
§program_id: &'info PubkeyCurrently executing program id.
accounts: &'info mut TDeserialized accounts.
remaining_accounts: &'info [AccountInfo<'info>]Remaining accounts given but not deserialized or validated. Be very careful when using this directly.
bumps: T::BumpsBump seeds found during constraint validation. This is provided as a convenience so that handlers don’t have to recalculate bump seeds or pass them in as arguments. Type is the bumps struct generated by #[derive(Accounts)]
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<'info, T> !RefUnwindSafe for Context<'info, T>
impl<'info, T> !Send for Context<'info, T>
impl<'info, T> !Sync for Context<'info, T>
impl<'info, T> !UnwindSafe for Context<'info, T>
impl<'info, T> Freeze for Context<'info, T>
impl<'info, T> Unpin for Context<'info, T>
impl<'info, T> UnsafeUnpin for Context<'info, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more