Skip to main content

Rent

Struct Rent 

Source
#[repr(C)]
pub struct Rent { pub lamports_per_byte_year: u64, pub exemption_threshold: f64, pub burn_percent: u8, }
Expand description

Rent sysvar data.

Fields§

§lamports_per_byte_year: u64§exemption_threshold: f64§burn_percent: u8

Implementations§

Source§

impl Rent

Source

pub fn get() -> Result<Self, ProgramError>

Read the Rent sysvar.

Method-style alias for get_rent, matching the Sysvar::get() ergonomics other Solana frameworks expose (Rent::get()).

Source

pub fn minimum_balance(&self, data_len: usize) -> u64

Minimum lamports for rent exemption at data_len, computed from the live sysvar values, the correct source for reaping-relevant decisions after a rent reprice.

This follows Solana’s own solana_rent::Rent::minimum_balance for the two thresholds any cluster has stored, with no floating point at all:

integer_part = (ACCOUNT_STORAGE_OVERHEAD + data_len) * rate
threshold 1.0 => integer_part
threshold 2.0 => integer_part * 2
otherwise     => integer_part * ceil(threshold)   (never below Solana's
                 `(integer_part as f64 * threshold) as u64`)

SIMD-0194 made 1.0 the live wire marker and moved the full price into the rate field; 2.0 is the launch-era value. Both are matched by bit pattern (see scale_by_exemption_threshold), so a program that reads the sysvar links no soft-float code. A threshold no cluster has ever used rounds up to whole years, which can only overfund.

The integer product uses saturating ops purely as an overflow guard; for every loader-permitted data_len (<= 10_485_760) and realistic lamports_per_byte_year it never saturates, so the byte-match with the runtime is exact (proven in the Kani harnesses below).

Trait Implementations§

Source§

impl Clone for Rent

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Rent

Source§

impl Debug for Rent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Rent

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.