pub struct PDA<'a, 'info> { /* private fields */ }Implementations§
Source§impl<'a, 'info> PDA<'a, 'info>
impl<'a, 'info> PDA<'a, 'info>
pub fn new( info: &'a AccountInfo<'info>, known_address: &Pubkey, ) -> Result<PDA<'a, 'info>, ProgramError>
Methods from Deref<Target = AccountInfo<'info>>§
pub fn signer_key(&self) -> Option<&Pubkey>
pub fn unsigned_key(&self) -> &Pubkey
pub fn lamports(&self) -> u64
pub fn try_lamports(&self) -> Result<u64, ProgramError>
Sourcepub unsafe fn original_data_len(&self) -> usize
pub unsafe fn original_data_len(&self) -> usize
Return the account’s original data length when it was serialized for the current program invocation.
§Safety
This method assumes that the original data length was serialized as a u32 integer in the 4 bytes immediately preceding the serialized account key.
pub fn data_len(&self) -> usize
pub fn try_data_len(&self) -> Result<usize, ProgramError>
pub fn data_is_empty(&self) -> bool
pub fn try_data_is_empty(&self) -> Result<bool, ProgramError>
pub fn try_borrow_lamports(&self) -> Result<Ref<'_, &mut u64>, ProgramError>
pub fn try_borrow_mut_lamports( &self, ) -> Result<RefMut<'_, &'a mut u64>, ProgramError>
pub fn try_borrow_data(&self) -> Result<Ref<'_, &mut [u8]>, ProgramError>
pub fn try_borrow_mut_data( &self, ) -> Result<RefMut<'_, &'a mut [u8]>, ProgramError>
Sourcepub fn realloc(
&self,
new_len: usize,
zero_init: bool,
) -> Result<(), ProgramError>
👎Deprecated since 2.3.0: Use AccountInfo::resize() instead
pub fn realloc( &self, new_len: usize, zero_init: bool, ) -> Result<(), ProgramError>
Realloc the account’s data and optionally zero-initialize the new memory.
Note: Account data can be increased within a single call by up to
solana_program::entrypoint::MAX_PERMITTED_DATA_INCREASE bytes.
Note: zero_init being false will no longer be supported by the
program runtime.
§Safety
This method makes assumptions about the layout and location of memory
referenced by AccountInfo fields. It should only be called for
instances of AccountInfo that were created by the runtime and received
in the process_instruction entrypoint of a program.
Sourcepub fn resize(&self, new_len: usize) -> Result<(), ProgramError>
pub fn resize(&self, new_len: usize) -> Result<(), ProgramError>
Resize the account’s data: Either truncating or zero extending.
Note: Account data can be increased within a single call by up to
solana_program::entrypoint::MAX_PERMITTED_DATA_INCREASE bytes.
§Safety
This method makes assumptions about the layout and location of memory
referenced by AccountInfo fields. It should only be called for
instances of AccountInfo that were created by the runtime and received
in the process_instruction entrypoint of a program.
pub fn assign(&self, new_owner: &Pubkey)
pub fn deserialize_data<T>(&self) -> Result<T, Box<ErrorKind>>where
T: DeserializeOwned,
pub fn serialize_data<T>(&self, state: &T) -> Result<(), Box<ErrorKind>>where
T: Serialize,
Trait Implementations§
Source§impl<'a, 'info> AsRef<AccountInfo<'info>> for PDA<'a, 'info>
impl<'a, 'info> AsRef<AccountInfo<'info>> for PDA<'a, 'info>
Source§fn as_ref(&self) -> &AccountInfo<'info>
fn as_ref(&self) -> &AccountInfo<'info>
Auto Trait Implementations§
impl<'a, 'info> Freeze for PDA<'a, 'info>
impl<'a, 'info> !RefUnwindSafe for PDA<'a, 'info>
impl<'a, 'info> !Send for PDA<'a, 'info>
impl<'a, 'info> !Sync for PDA<'a, 'info>
impl<'a, 'info> Unpin for PDA<'a, 'info>
impl<'a, 'info> !UnwindSafe for PDA<'a, 'info>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more