error_stack/frame/
kind.rs

1use core::fmt::{Debug, Display};
2
3use crate::Context;
4
5/// Classification of the contents of a [`Frame`], determined by how it was created.
6///
7/// [`Frame`]: crate::Frame
8pub enum FrameKind<'f> {
9    /// Frame was created through [`Report::new()`] or [`change_context()`].
10    ///
11    /// [`Report::new()`]: crate::Report::new
12    /// [`change_context()`]: crate::Report::change_context
13    Context(&'f dyn Context),
14    /// Frame was created through [`attach()`] or [`attach_printable()`].
15    ///
16    /// [`attach()`]: crate::Report::attach
17    /// [`attach_printable()`]: crate::Report::attach_printable
18    Attachment(AttachmentKind<'f>),
19}
20
21/// Classification of an attachment which is determined by the method it was created in.
22#[non_exhaustive]
23pub enum AttachmentKind<'f> {
24    /// A generic attachment created through [`attach()`].
25    ///
26    /// [`attach()`]: crate::Report::attach
27    Opaque(&'f (dyn Send + Sync + 'static)),
28    /// A printable attachment created through [`attach_printable()`].
29    ///
30    /// [`attach_printable()`]: crate::Report::attach_printable
31    Printable(&'f dyn Printable),
32}
33
34// TODO: Replace `Printable` by trait bounds when trait objects for multiple traits are supported.
35//   see https://github.com/rust-lang/rfcs/issues/2035
36pub trait Printable: Debug + Display + Send + Sync + 'static {}
37impl<T> Printable for T where T: Debug + Display + Send + Sync + 'static {}