pub struct MemScopeGuard { /* private fields */ }Expand description
RAII handle that keeps the auto-export subsystem alive.
Created by start / start_with. Dropping it joins the optional
background flusher and then triggers the idempotent exit-path export via
lifecycle::export_once. The guard also derefs to GlobalTracker so
callers can use track! / track_as / export_html directly on it.
Implementations§
Source§impl MemScopeGuard
impl MemScopeGuard
Sourcepub fn tracker(&self) -> &Arc<GlobalTracker> ⓘ
pub fn tracker(&self) -> &Arc<GlobalTracker> ⓘ
Borrow the underlying tracker handle.
The returned Arc is the same one registered with the global singleton
and the lifecycle hooks, so callers can compare pointers or share it
across threads without re-fetching the singleton.
Sourcepub fn export_now(&self) -> bool
pub fn export_now(&self) -> bool
Trigger an immediate export. Resets the idempotency latch first so a later panic / Ctrl-C / Drop still produces a fresh report.
§Returns
true if the export ran; false if no tracker / config is installed
(e.g. after reset_for_test).
Sourcepub fn snapshot_json(&self) -> MemScopeResult<String>
pub fn snapshot_json(&self) -> MemScopeResult<String>
In-memory JSON snapshot (no disk write). Builds an AnalysisReport
via the analyzer pipeline and serializes it. Intended for HTTP
endpoints or ad-hoc inspection without touching the filesystem.
§Errors
Returns MemScopeError if no tracker is installed (e.g. after
reset_global_tracking) or if serialization of the analysis report
fails.
Methods from Deref<Target = GlobalTracker>§
pub fn tracker(&self) -> &Tracker
pub fn passport_tracker(&self) -> &Arc<MemoryPassportTracker> ⓘ
pub fn async_tracker(&self) -> &Arc<AsyncTracker> ⓘ
pub fn elapsed(&self) -> Duration
pub fn track<T: Trackable>(&self, var: &T)
pub fn track_as<T: Trackable>( &self, var: &T, name: &str, file: &str, line: u32, module_path: &str, )
pub fn create_passport( &self, ptr: usize, size: usize, context: String, ) -> Result<String, TrackingError>
pub fn record_handover(&self, ptr: usize, context: String, function: String)
pub fn record_free(&self, ptr: usize, context: String, function: String)
pub fn detect_leaks(&self) -> LeakDetectionResult
pub fn analyze(&self) -> AnalysisReport
pub fn get_stats(&self) -> GlobalTrackerStats
pub fn export_json<P: AsRef<Path>>(&self, path: P) -> MemScopeResult<()>
pub fn export_html<P: AsRef<Path>>(&self, path: P) -> MemScopeResult<()>
pub fn export_html_with_template<P: AsRef<Path>>( &self, path: P, template: DashboardTemplate, ) -> MemScopeResult<()>
Trait Implementations§
Source§impl Deref for MemScopeGuard
impl Deref for MemScopeGuard
Source§impl Drop for MemScopeGuard
impl Drop for MemScopeGuard
Auto Trait Implementations§
impl !Freeze for MemScopeGuard
impl !RefUnwindSafe for MemScopeGuard
impl !UnwindSafe for MemScopeGuard
impl Send for MemScopeGuard
impl Sync for MemScopeGuard
impl Unpin for MemScopeGuard
impl UnsafeUnpin for MemScopeGuard
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
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>
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>
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