pub struct ResourceTracker { /* private fields */ }Expand description
Tracks resource usage and enforces limits.
Implementations§
Source§impl ResourceTracker
impl ResourceTracker
Sourcepub fn new(limits: ResourceLimits) -> Self
pub fn new(limits: ResourceLimits) -> Self
Create a new tracker with the given limits.
Sourcepub fn check_can_write(
&self,
agent_id: AgentId,
estimated_bytes: u64,
) -> MenteResult<()>
pub fn check_can_write( &self, agent_id: AgentId, estimated_bytes: u64, ) -> MenteResult<()>
Check whether a write is allowed given current usage.
Sourcepub fn record_write(&self, agent_id: AgentId, bytes: u64)
pub fn record_write(&self, agent_id: AgentId, bytes: u64)
Record that a write occurred.
Sourcepub fn record_delete(&self, agent_id: AgentId, bytes: u64)
pub fn record_delete(&self, agent_id: AgentId, bytes: u64)
Record that a delete occurred.
Sourcepub fn usage(&self) -> ResourceUsage
pub fn usage(&self) -> ResourceUsage
Get a snapshot of current resource usage.
Auto Trait Implementations§
impl !Freeze for ResourceTracker
impl !RefUnwindSafe for ResourceTracker
impl Send for ResourceTracker
impl Sync for ResourceTracker
impl Unpin for ResourceTracker
impl UnsafeUnpin for ResourceTracker
impl UnwindSafe for ResourceTracker
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