pub struct ResourceMonitor { /* private fields */ }Expand description
Monitors and enforces resource limits
Implementations§
Source§impl ResourceMonitor
impl ResourceMonitor
Sourcepub fn with_limits(limits: ResourceLimits) -> Self
pub fn with_limits(limits: ResourceLimits) -> Self
Create a new resource monitor with custom limits
Sourcepub async fn try_acquire_task_permit(
&self,
) -> Result<TaskPermit, ResourceExhausted>
pub async fn try_acquire_task_permit( &self, ) -> Result<TaskPermit, ResourceExhausted>
Try to acquire a permit to spawn a new task
Returns Ok(permit) if under limits, Err if at capacity
Sourcepub fn stats(&self) -> ResourceStats
pub fn stats(&self) -> ResourceStats
Get current resource statistics
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics (keeps limits)
Sourcepub fn check_recursion_depth(
&self,
depth: usize,
) -> Result<(), ResourceExhausted>
pub fn check_recursion_depth( &self, depth: usize, ) -> Result<(), ResourceExhausted>
Check if recursion depth exceeds limit
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResourceMonitor
impl !RefUnwindSafe for ResourceMonitor
impl Send for ResourceMonitor
impl Sync for ResourceMonitor
impl Unpin for ResourceMonitor
impl !UnwindSafe for ResourceMonitor
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
Source§impl<T> Inspectable for T
impl<T> Inspectable for T
Source§fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
fn inspect_if(self, condition: bool, label: &str) -> Selfwhere
Self: Debug,
Conditionally inspect this value
Source§fn inspect_with<F>(self, label: &str, f: F) -> Self
fn inspect_with<F>(self, label: &str, f: F) -> Self
Inspect with a custom formatter