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