pub struct ManagedMemoryPolicy { /* private fields */ }Expand description
The policy that derives the chargeable managed memory budget.
The resolved budget is
min(requested_managed, effective_limit - headroom_bytes), where
effective_limit is the smaller of the detected limit and an explicitly
configured limit. No ratio or headroom is imposed by default: the default
charges the whole effective limit, which is the behavior that existed before
this policy, so adopting a measured ratio stays an explicit opt-in. Lowering
a budget does not revoke permits that were already granted; it bounds new
admission.
Implementations§
Source§impl ManagedMemoryPolicy
impl ManagedMemoryPolicy
Sourcepub const fn whole_limit() -> Self
pub const fn whole_limit() -> Self
Charges the entire effective limit.
Sourcepub fn explicit_bytes(bytes: u64) -> Result<Self, RuntimeContractViolation>
pub fn explicit_bytes(bytes: u64) -> Result<Self, RuntimeContractViolation>
Charges an explicit byte count.
§Errors
Returns a contract violation when bytes is zero, which could only
produce a zero budget.
Sourcepub fn fraction(
numerator: u64,
denominator: u64,
) -> Result<Self, RuntimeContractViolation>
pub fn fraction( numerator: u64, denominator: u64, ) -> Result<Self, RuntimeContractViolation>
Charges a fraction of the effective limit.
§Errors
Returns a contract violation for a zero, inverted, or out-of-range fraction.
Sourcepub const fn with_headroom(self, headroom_bytes: u64) -> Self
pub const fn with_headroom(self, headroom_bytes: u64) -> Self
Reserves bytes that the ledger must leave unused inside the limit.
Sourcepub const fn request(self) -> ManagedMemoryRequest
pub const fn request(self) -> ManagedMemoryRequest
Returns how the requested managed bytes are derived.
Sourcepub const fn headroom_bytes(self) -> u64
pub const fn headroom_bytes(self) -> u64
Returns the reserved headroom.