Struct Backtrace

#[must_use]
pub struct Backtrace { pub(in ::backtrace) inner: Inner }

A captured OS thread stack backtrace.

This type represents a stack backtrace for an OS thread captured at a previous point in time. In some instances the Backtrace type may internally be empty due to configuration. For more information see Backtrace::capture.

Fields

inner: Inner

Implementations

impl Backtrace

fn enabled() -> bool

Returns whether backtrace captures are enabled through environment variables.

fn capture() -> Backtrace

Captures a stack backtrace of the current thread.

This function will capture a stack backtrace of the current OS thread of execution, returning a Backtrace type which can be later used to print the entire stack trace or render it to a string.

This function will be a noop if the RUST_BACKTRACE or RUST_LIB_BACKTRACE backtrace variables are both not set. If either environment variable is set and enabled then this function will actually capture a backtrace. Capturing a backtrace can be both memory intensive and slow, so these environment variables allow liberally using Backtrace::capture and only incurring a slowdown when the environment variables are set.

To forcibly capture a backtrace regardless of environment variables, use the Backtrace::force_capture function.

fn force_capture() -> Backtrace

Forcibly captures a full backtrace, regardless of environment variable configuration.

This function behaves the same as capture except that it ignores the values of the RUST_BACKTRACE and RUST_LIB_BACKTRACE environment variables, always capturing a backtrace.

Note that capturing a backtrace can be an expensive operation on some platforms, so this should be used with caution in performance-sensitive parts of code.

const fn disabled() -> Backtrace

Forcibly captures a disabled backtrace, regardless of environment variable configuration.

fn create(ip: usize) -> Backtrace
fn status(&self) -> BacktraceStatus

Returns the status of this backtrace, indicating whether this backtrace request was unsupported, disabled, or a stack trace was actually captured.

impl<'a> Backtrace

fn frames(&'a self) -> &'a [BacktraceFrame]

Returns an iterator over the backtrace frames.

Trait Implementations

impl Debug for Backtrace

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

impl Display for Backtrace

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl !Freeze for Backtrace

impl RefUnwindSafe for Backtrace

impl Send for Backtrace

impl Sync for Backtrace

impl Unpin for Backtrace

impl UnsafeUnpin for Backtrace

impl UnwindSafe for Backtrace

Blanket Implementations

impl<T> Any for Backtrace where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Backtrace where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Backtrace where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for Backtrace

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Backtrace where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Backtrace

impl<T> ToString for Backtrace where T: Display + ?Sized,

fn to_string(&self) -> String

impl<T, U> Into<U> for Backtrace where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Backtrace where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Backtrace where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>