#[repr(C)]pub struct Rent {
pub lamports_per_byte: u64,
pub exemption_threshold: [u8; 8],
pub burn_percent: u8,
}Expand description
Configuration of network rent.
Fields§
§lamports_per_byte: u64Rental rate in lamports/byte.
exemption_threshold: [u8; 8]Use Rent::minimum_balance() directly
Formerly, the amount of time (in years) a balance must include rent for the account to be rent exempt. Now it’s just empty space.
burn_percent: u8Rent no longer exists
Formerly, the percentage of collected rent that is burned.
Implementations§
Source§impl Rent
impl Rent
Sourcepub fn minimum_balance(&self, data_len: usize) -> u64
pub fn minimum_balance(&self, data_len: usize) -> u64
Calculates the minimum balance for rent exemption.
This method avoids floating-point operations when the exemption_threshold
is the default value.
§Arguments
data_len- The number of bytes in the account
§Returns
The minimum balance in lamports for rent exemption.
§Panics
Panics if data_len exceeds the maximum permitted data length or if the
lamports_per_byte is too large based on the exemption_threshold.
Sourcepub fn minimum_balance_unchecked(&self, data_len: usize) -> u64
pub fn minimum_balance_unchecked(&self, data_len: usize) -> u64
Calculates the minimum balance for rent exemption without performing any validation.
This method avoids floating-point operations when the exemption_threshold
is the default value.
§Important
The caller must ensure that data_len is within the permitted limit
and the lamports_per_byte is within the permitted limit based on
the exemption_threshold to avoid overflow.
§Arguments
data_len- The number of bytes in the account
§Returns
The minimum balance in lamports for rent exemption.
Sourcepub fn try_minimum_balance(&self, data_len: usize) -> Option<u64>
pub fn try_minimum_balance(&self, data_len: usize) -> Option<u64>
Calculates the minimum balance for rent exemption.
This method avoids floating-point operations when the exemption_threshold
is the default value.
§Arguments
data_len- The number of bytes in the account
§Returns
Some(u64)- The minimum balance in lamports for rent exemption, if all checks pass.None- Ifdata_lenexceeds the maximum permitted data length, or if thelamports_per_byteis too large based on theexemption_threshold, which would cause an overflow.
Sourcepub fn is_exempt(&self, balance: u64, data_len: usize) -> bool
pub fn is_exempt(&self, balance: u64, data_len: usize) -> bool
Whether a given balance and data length would be exempt.
Sourcepub fn with_lamports_per_byte(lamports_per_byte: u64) -> Rent
pub fn with_lamports_per_byte(lamports_per_byte: u64) -> Rent
Creates a Rent with lamports per byte
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Rent
impl<'de> Deserialize<'de> for Rent
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rent, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for Rent
impl Serialize for Rent
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Rent
Source§impl SysvarSerialize for Rent
Available on crate feature bincode only.
impl SysvarSerialize for Rent
bincode only.Source§fn from_account_info(
account_info: &AccountInfo<'_>,
) -> Result<Self, ProgramError>
fn from_account_info( account_info: &AccountInfo<'_>, ) -> Result<Self, ProgramError>
AccountInfo. Read moreSource§fn to_account_info(&self, account_info: &mut AccountInfo<'_>) -> Option<()>
fn to_account_info(&self, account_info: &mut AccountInfo<'_>) -> Option<()>
AccountInfo. Read moreAuto Trait Implementations§
impl Freeze for Rent
impl RefUnwindSafe for Rent
impl Send for Rent
impl Sync for Rent
impl Unpin for Rent
impl UnsafeUnpin for Rent
impl UnwindSafe for Rent
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
impl<T> AbiEnumVisitor for Twhere
T: Serialize + AbiExample,
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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