Skip to main content

Capturable

Trait Capturable 

Source
pub trait Capturable {
    // Required method
    fn capture() -> Self;

    // Provided method
    fn capture_or_extract(source: &dyn Diagnostic) -> Self
       where Self: Sized { ... }
}
Expand description

A value that fills itself in when an error is constructed.

A field marked #[oopsie(capture)] is populated by calling capture at construction time, so it is dropped from the context selector and never supplied by the caller. The library implements Capturable for backtraces, span-traces (with the tracing feature), SystemTime/Instant timestamps (plus chrono::DateTime<Local> under the chrono feature and jiff::Timestamp/jiff::Zoned under the jiff feature), the caller Location, and the environment snapshots in the extras module. Implement it for your own type to capture anything else, such as a request or thread id.

It also covers Box, Rc, Arc, and tuples, so one field can wrap or combine several captured values.

Required Methods§

Source

fn capture() -> Self

Capture a fresh value at the point the error is constructed.

Provided Methods§

Source

fn capture_or_extract(source: &dyn Diagnostic) -> Self
where Self: Sized,

Capture for an error that wraps source, reusing equivalent data already on source when that is more useful than a fresh capture.

The default ignores source and calls capture; trace types override it so wrapping another diagnostic preserves the source’s original call site instead of recording the wrap site. Rarely called or overridden by hand.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Capturable for &'static Location<'static>

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl Capturable for DateTime<Local>

Available on crate feature chrono only.
Source§

fn capture() -> Self

Source§

impl Capturable for Instant

Available on crate feature std only.
Source§

fn capture() -> Self

Source§

impl Capturable for SystemTime

Available on crate feature std only.
Source§

fn capture() -> Self

Source§

impl Capturable for Timestamp

Available on crate feature jiff only.
Source§

fn capture() -> Self

Source§

impl Capturable for Zoned

Available on crate feature jiff only.
Source§

fn capture() -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable, E: Capturable, F: Capturable, G: Capturable, H: Capturable, I: Capturable> Capturable for (A, B, C, D, E, F, G, H, I)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable, E: Capturable, F: Capturable, G: Capturable, H: Capturable> Capturable for (A, B, C, D, E, F, G, H)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable, E: Capturable, F: Capturable, G: Capturable> Capturable for (A, B, C, D, E, F, G)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable, E: Capturable, F: Capturable> Capturable for (A, B, C, D, E, F)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable, E: Capturable> Capturable for (A, B, C, D, E)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable, D: Capturable> Capturable for (A, B, C, D)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable, C: Capturable> Capturable for (A, B, C)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable, B: Capturable> Capturable for (A, B)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<A: Capturable> Capturable for (A,)

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<T: Capturable> Capturable for Arc<T>

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<T: Capturable> Capturable for Box<T>

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Source§

impl<T: Capturable> Capturable for Rc<T>

Source§

fn capture() -> Self

Source§

fn capture_or_extract(source: &dyn Diagnostic) -> Self

Implementors§