pub struct MemCtx { /* private fields */ }Expand description
Implementations§
Source§impl MemCtx
impl MemCtx
Sourcepub fn init() -> MemScopeResult<Self>
pub fn init() -> MemScopeResult<Self>
Initialise logging + global tracking in one call.
Sourcepub fn start() -> MemScopeResult<MemScopeGuard>
pub fn start() -> MemScopeResult<MemScopeGuard>
One-line start with the default configuration.
Equivalent to MemCtx::start_with(MemScopeConfig::default()). The
returned MemScopeGuard triggers the exit-path export (HTML + JSON
to ./memscope-report) on drop, covering normal return, panic, and —
when the auto-signal feature is enabled — Ctrl-C.
This is the recommended entry point for new code. Existing code that
calls MemCtx::init + MemCtx::export continues to work unchanged.
§Errors
Returns MemScopeError if logging init, global
tracker init, or lifecycle hook installation fails.
Sourcepub fn start_with(config: MemScopeConfig) -> MemScopeResult<MemScopeGuard>
pub fn start_with(config: MemScopeConfig) -> MemScopeResult<MemScopeGuard>
One-line start with a custom MemScopeConfig.
Like MemCtx::start but accepts a user-supplied configuration for
output path, formats, signal policy, and periodic flush interval.
The returned MemScopeGuard owns the optional background flusher
and triggers the exit-path export on drop.
§Errors
Returns MemScopeError if any of the setup
steps fails. A repeated call without reset_global_tracking fails at
the global-tracker init step.
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§
Auto Trait Implementations§
impl !RefUnwindSafe for MemCtx
impl !UnwindSafe for MemCtx
impl Freeze for MemCtx
impl Send for MemCtx
impl Sync for MemCtx
impl Unpin for MemCtx
impl UnsafeUnpin for MemCtx
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