pub struct ResourceGuard {
pub config: ResourceGuardConfig,
/* private fields */
}Expand description
Resource guard for monitoring system resources.
Fields§
§config: ResourceGuardConfigConfiguration (public so callers can tune thresholds before with_config).
Implementations§
Source§impl ResourceGuard
impl ResourceGuard
Sourcepub fn with_config(config: ResourceGuardConfig) -> Self
pub fn with_config(config: ResourceGuardConfig) -> Self
Create a new resource guard with custom configuration.
Sourcepub async fn should_pause(&self) -> bool
pub async fn should_pause(&self) -> bool
Check if indexing should be paused based on current resource state.
Sourcepub async fn pause_reason(&self) -> Option<PauseReason>
pub async fn pause_reason(&self) -> Option<PauseReason>
Get the current pause reason, if any.
Sourcepub fn start_monitoring(&self, sender: Sender<PauseReason>)
pub fn start_monitoring(&self, sender: Sender<PauseReason>)
Start monitoring resources and send pause/resume signals.
Runs until the task is aborted. Sends a PauseReason whenever the
pause state changes: the specific reason on pause, Resumed on resume.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ResourceGuard
impl !UnwindSafe for ResourceGuard
impl Forget for ResourceGuard
impl Freeze for ResourceGuard
impl Move for ResourceGuard
impl Send for ResourceGuard
impl Sync for ResourceGuard
impl Unpin for ResourceGuard
impl UnsafeUnpin for ResourceGuard
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more