pub struct Rent {
pub lamports_per_byte: u64,
/* private fields */
}Expand description
Configuration of network rent.
Fields§
§lamports_per_byte: u64Rental rate in lamports/byte.
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
The minimum balance in lamports for rent exemption.
§Errors
Returns ProgramError::InvalidArgument if data_len exceeds the maximum
permitted data length or if the lamports_per_byte is too large based on
the exemption_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,
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 moreimpl StructuralPartialEq for Rent
Auto 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
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