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§
Provided Methods§
Sourcefn capture_or_extract(source: &dyn Diagnostic) -> Selfwhere
Self: Sized,
fn capture_or_extract(source: &dyn Diagnostic) -> Selfwhere
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>
impl Capturable for &'static Location<'static>
fn capture() -> Self
fn capture_or_extract(source: &dyn Diagnostic) -> Self
Source§impl Capturable for DateTime<Local>
Available on crate feature chrono only.
impl Capturable for DateTime<Local>
chrono only.Source§impl Capturable for SystemTime
Available on crate feature std only.
impl Capturable for SystemTime
std only.Source§impl Capturable for Timestamp
Available on crate feature jiff only.
impl Capturable for Timestamp
jiff only.