#[repr(C)]pub struct CompressionInfo {
pub config_account_version: u16,
pub compress_to_pubkey: u8,
pub account_version: u8,
pub lamports_per_write: u32,
pub compression_authority: [u8; 32],
pub rent_sponsor: [u8; 32],
pub last_claimed_slot: u64,
pub rent_exemption_paid: u32,
pub _reserved: u32,
pub rent_config: RentConfig,
}Expand description
Compressible extension for ctoken accounts.
Fields§
§config_account_version: u16§compress_to_pubkey: u8Compress to account pubkey instead of account owner.
account_version: u8Version of the compressed token account when ctoken account is compressed and closed. (The account_version specifies the hashing scheme.)
lamports_per_write: u32Lamports amount the account is topped up with at every write by the fee payer.
Authority that can compress and close the account.
rent_sponsor: [u8; 32]Recipient for rent exemption lamports up on account closure.
last_claimed_slot: u64Last slot rent was claimed from this account.
rent_exemption_paid: u32Rent exemption lamports paid at account creation. Used instead of querying the Rent sysvar to ensure rent sponsor gets back exactly what they paid regardless of future rent changes.
_reserved: u32Reserved for future use.
rent_config: RentConfigRent function parameters, used to calculate whether the account is compressible.
Implementations§
Source§impl CompressionInfo
impl CompressionInfo
Sourcepub fn is_compressible(
&self,
bytes: u64,
current_slot: u64,
current_lamports: u64,
) -> Result<Option<u64>, CompressibleError>
pub fn is_compressible( &self, bytes: u64, current_slot: u64, current_lamports: u64, ) -> Result<Option<u64>, CompressibleError>
current - last epoch = num epochs due rent_due available_balance = current_lamports - last_lamports (we can never claim more lamports than rent is due) remaining_balance = available_balance - rent_due
Sourcepub fn compress_to_pubkey(&self) -> bool
pub fn compress_to_pubkey(&self) -> bool
Converts the compress_to_pubkey field into a boolean.
Sourcepub fn calculate_top_up_lamports(
&self,
num_bytes: u64,
current_slot: u64,
current_lamports: u64,
) -> Result<u64, CompressibleError>
pub fn calculate_top_up_lamports( &self, num_bytes: u64, current_slot: u64, current_lamports: u64, ) -> Result<u64, CompressibleError>
Calculate the amount of lamports to top up during a write operation. Returns 0 if no top-up is needed (account is well-funded). Returns write_top_up + rent_deficit if account is compressible. Returns write_top_up if account needs more funding but isn’t compressible yet.
Source§impl CompressionInfo
impl CompressionInfo
Sourcepub fn get_last_funded_epoch(
&self,
num_bytes: u64,
current_lamports: u64,
rent_exemption_lamports: u64,
) -> Result<u64, CompressibleError>
pub fn get_last_funded_epoch( &self, num_bytes: u64, current_lamports: u64, rent_exemption_lamports: u64, ) -> Result<u64, CompressibleError>
Get the last epoch that has been paid for. Returns the epoch number through which rent has been prepaid.
Trait Implementations§
Source§impl BorshDeserialize for CompressionInfowhere
u16: BorshDeserialize,
u8: BorshDeserialize,
u32: BorshDeserialize,
[u8; 32]: BorshDeserialize,
u64: BorshDeserialize,
RentConfig: BorshDeserialize,
impl BorshDeserialize for CompressionInfowhere
u16: BorshDeserialize,
u8: BorshDeserialize,
u32: BorshDeserialize,
[u8; 32]: BorshDeserialize,
u64: BorshDeserialize,
RentConfig: BorshDeserialize,
fn deserialize_reader<R>(reader: &mut R) -> Result<CompressionInfo, Error>where
R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for CompressionInfowhere
u16: BorshSerialize,
u8: BorshSerialize,
u32: BorshSerialize,
[u8; 32]: BorshSerialize,
u64: BorshSerialize,
RentConfig: BorshSerialize,
impl BorshSerialize for CompressionInfowhere
u16: BorshSerialize,
u8: BorshSerialize,
u32: BorshSerialize,
[u8; 32]: BorshSerialize,
u64: BorshSerialize,
RentConfig: BorshSerialize,
Source§impl Clone for CompressionInfo
impl Clone for CompressionInfo
Source§fn clone(&self) -> CompressionInfo
fn clone(&self) -> CompressionInfo
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompressionInfo
impl Debug for CompressionInfo
Source§impl Default for CompressionInfo
impl Default for CompressionInfo
Source§fn default() -> CompressionInfo
fn default() -> CompressionInfo
Source§impl Hash for CompressionInfo
impl Hash for CompressionInfo
Source§impl PartialEq for CompressionInfo
impl PartialEq for CompressionInfo
Source§impl<'a> ZeroCopyAt<'a> for CompressionInfo
impl<'a> ZeroCopyAt<'a> for CompressionInfo
type ZeroCopyAt = ZCompressionInfo<'a>
fn zero_copy_at( __remaining_bytes: &'a [u8], ) -> Result<(<CompressionInfo as ZeroCopyAt<'a>>::ZeroCopyAt, &'a [u8]), ZeroCopyError>
Source§impl<'a> ZeroCopyAtMut<'a> for CompressionInfo
impl<'a> ZeroCopyAtMut<'a> for CompressionInfo
type ZeroCopyAtMut = ZCompressionInfoMut<'a>
fn zero_copy_at_mut( __remaining_bytes: &'a mut [u8], ) -> Result<(<CompressionInfo as ZeroCopyAtMut<'a>>::ZeroCopyAtMut, &'a mut [u8]), ZeroCopyError>
Source§impl<'a> ZeroCopyNew<'a> for CompressionInfo
impl<'a> ZeroCopyNew<'a> for CompressionInfo
Source§type ZeroCopyConfig = CompressionInfoConfig
type ZeroCopyConfig = CompressionInfoConfig
Source§type Output = <CompressionInfo as ZeroCopyAtMut<'a>>::ZeroCopyAtMut
type Output = <CompressionInfo as ZeroCopyAtMut<'a>>::ZeroCopyAtMut
Source§fn byte_len(
config: &<CompressionInfo as ZeroCopyNew<'a>>::ZeroCopyConfig,
) -> Result<usize, ZeroCopyError>
fn byte_len( config: &<CompressionInfo as ZeroCopyNew<'a>>::ZeroCopyConfig, ) -> Result<usize, ZeroCopyError>
Source§fn new_zero_copy(
__remaining_bytes: &'a mut [u8],
config: <CompressionInfo as ZeroCopyNew<'a>>::ZeroCopyConfig,
) -> Result<(<CompressionInfo as ZeroCopyNew<'a>>::Output, &'a mut [u8]), ZeroCopyError>
fn new_zero_copy( __remaining_bytes: &'a mut [u8], config: <CompressionInfo as ZeroCopyNew<'a>>::ZeroCopyConfig, ) -> Result<(<CompressionInfo as ZeroCopyNew<'a>>::Output, &'a mut [u8]), ZeroCopyError>
Source§impl ZeroCopyStructInner for CompressionInfo
impl ZeroCopyStructInner for CompressionInfo
type ZeroCopyInner = ZCompressionInfo<'static>
Source§impl ZeroCopyStructInnerMut for CompressionInfo
impl ZeroCopyStructInnerMut for CompressionInfo
type ZeroCopyInnerMut = ZCompressionInfoMut<'static>
impl Copy for CompressionInfo
impl Eq for CompressionInfo
impl Pod for CompressionInfo
impl StructuralPartialEq for CompressionInfo
Auto Trait Implementations§
impl Freeze for CompressionInfo
impl RefUnwindSafe for CompressionInfo
impl Send for CompressionInfo
impl Sync for CompressionInfo
impl Unpin for CompressionInfo
impl UnwindSafe for CompressionInfo
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> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
Source§type Bits = T
type Bits = T
Self must have the same layout as the specified Bits except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern.Source§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
bits
as &Self.Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> HashToFieldSize for Twhere
T: BorshSerialize,
impl<T> HashToFieldSize for Twhere
T: BorshSerialize,
fn hash_to_field_size(&self) -> Result<[u8; 32], HasherError>
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