pub struct ResourceTracker { /* private fields */ }Expand description
Resource tracker for enforcing limits.
Implementations§
Source§impl ResourceTracker
impl ResourceTracker
Sourcepub fn new(limits: ResourceLimits) -> Self
pub fn new(limits: ResourceLimits) -> Self
Creates a new tracker with the given limits.
Sourcepub fn usage(&self) -> ResourceUsage
pub fn usage(&self) -> ResourceUsage
Returns the current usage snapshot.
Sourcepub fn limits(&self) -> ResourceLimits
pub fn limits(&self) -> ResourceLimits
Returns the configured limits.
Sourcepub fn add_observer(&self, observer: Box<dyn ResourceObserver>)
pub fn add_observer(&self, observer: Box<dyn ResourceObserver>)
Adds a resource observer.
Sourcepub fn can_acquire(&self, request: &ResourceRequest) -> bool
pub fn can_acquire(&self, request: &ResourceRequest) -> bool
Returns whether a request can be satisfied.
Sourcepub fn try_acquire_encoding(
&self,
memory_needed: usize,
) -> Result<ResourceGuard, ResourceExhausted>
pub fn try_acquire_encoding( &self, memory_needed: usize, ) -> Result<ResourceGuard, ResourceExhausted>
Attempts to acquire resources for encoding.
Sourcepub fn try_acquire_decoding(
&self,
memory_needed: usize,
) -> Result<ResourceGuard, ResourceExhausted>
pub fn try_acquire_decoding( &self, memory_needed: usize, ) -> Result<ResourceGuard, ResourceExhausted>
Attempts to acquire resources for decoding.
Sourcepub fn try_acquire(
&self,
usage: ResourceUsage,
) -> Result<ResourceGuard, ResourceExhausted>
pub fn try_acquire( &self, usage: ResourceUsage, ) -> Result<ResourceGuard, ResourceExhausted>
Attempts to acquire a resource request.
Trait Implementations§
Source§impl Clone for ResourceTracker
impl Clone for ResourceTracker
Source§fn clone(&self) -> ResourceTracker
fn clone(&self) -> ResourceTracker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ResourceTracker
impl RefUnwindSafe for ResourceTracker
impl Send for ResourceTracker
impl Sync for ResourceTracker
impl Unpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).