pub struct LedgerQuota {
pub memory_bytes: u64,
pub frame_count: u64,
pub connection_count: u64,
}Expand description
账本令牌数据
Fields§
§memory_bytes: u64内存配额(字节)
frame_count: u64Frame 配额
connection_count: u64连接配额
Implementations§
Source§impl LedgerQuota
impl LedgerQuota
Sourcepub const fn zero() -> LedgerQuota
pub const fn zero() -> LedgerQuota
创建零配额
Sourcepub const fn unlimited() -> LedgerQuota
pub const fn unlimited() -> LedgerQuota
创建无限配额(仅用于根账本配置边界)
Sourcepub fn can_allocate(&self, child: &LedgerQuota) -> Result<(), CoreError>
pub fn can_allocate(&self, child: &LedgerQuota) -> Result<(), CoreError>
逐项检查子配额是否可以被父账本容纳
Sourcepub fn consume(
&mut self,
resource: ResourceType,
amount: u64,
) -> Result<(), CoreError>
pub fn consume( &mut self, resource: ResourceType, amount: u64, ) -> Result<(), CoreError>
消耗指定类型的配额(checked arithmetic)
Sourcepub fn restore(
&mut self,
resource: ResourceType,
amount: u64,
) -> Result<(), CoreError>
pub fn restore( &mut self, resource: ResourceType, amount: u64, ) -> Result<(), CoreError>
归还指定类型的配额(checked arithmetic)
Sourcepub fn get(&self, resource: ResourceType) -> u64
pub fn get(&self, resource: ResourceType) -> u64
获取指定类型的值
Sourcepub fn remaining(&self, used: &LedgerQuota) -> LedgerQuota
pub fn remaining(&self, used: &LedgerQuota) -> LedgerQuota
计算剩余配额 = total - used(饱和减法)
Trait Implementations§
Source§impl Clone for LedgerQuota
impl Clone for LedgerQuota
Source§fn clone(&self) -> LedgerQuota
fn clone(&self) -> LedgerQuota
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LedgerQuota
impl Debug for LedgerQuota
Source§impl Default for LedgerQuota
impl Default for LedgerQuota
Source§fn default() -> LedgerQuota
fn default() -> LedgerQuota
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LedgerQuota
impl RefUnwindSafe for LedgerQuota
impl Send for LedgerQuota
impl Sync for LedgerQuota
impl Unpin for LedgerQuota
impl UnsafeUnpin for LedgerQuota
impl UnwindSafe for LedgerQuota
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
Mutably borrows from an owned value. Read more