Struct error_stack::Report
source · [−]#[repr(transparent)]pub struct Report<C> { /* private fields */ }
Expand description
Contains a Frame
stack consisting of Context
s and attachments.
Attachments can be added by using attach()
. The Frame
stack can be iterated by using
frames()
.
When creating a Report
by using new()
, the passed Context
is used to set the current
context on the Report
. To provide a new one, use change_context()
.
Attachments, and objects provide
d by a Context
, are directly retrievable by calling
request_ref()
or request_value()
.
Multiple Errors
Report
is able to represent multiple errors that have occurred. Errors can be combined using
the extend_one()
, which will add the Frame
stack of the other error as an additional
source to the current report.
Backtrace
and SpanTrace
Report
is able to provide
a Backtrace
and a SpanTrace
, which can be retrieved by
calling request_ref::<Backtrace>()
or request_ref::<SpanTrace>()
(downcast_ref::<SpanTrace>()
on stable) respectively. If the root context provide
s a
Backtrace
or a SpanTrace
, those are returned, otherwise, if configured, an attempt is
made to capture them when creating a Report
. To enable capturing of the backtrace, make sure
RUST_BACKTRACE
or RUST_LIB_BACKTRACE
is set according to the Backtrace
documentation. To enable capturing of the span trace, an ErrorLayer
has to be
enabled. Please also see the Feature Flags section. A single Report
can have multiple
Backtrace
s and SpanTrace
s, depending on the amount of related errors the Report
consists of. Therefore it isn’t guaranteed that request_ref()
will only ever return a single
Backtrace
or SpanTrace
.
Examples
Provide a context for an error:
use error_stack::{IntoReport, ResultExt, Result};
let config_path = "./path/to/config.file";
let content = std::fs::read_to_string(config_path)
.into_report()
.attach_printable_lazy(|| format!("failed to read config file {config_path:?}"))?;
...
Enforce a context for an error:
use std::{fmt, path::{Path, PathBuf}};
use error_stack::{Context, IntoReport, Report, ResultExt};
#[derive(Debug)]
enum RuntimeError {
InvalidConfig(PathBuf),
...
}
#[derive(Debug)]
enum ConfigError {
IoError,
...
}
impl fmt::Display for RuntimeError {
...
}
impl fmt::Display for ConfigError {
...
}
impl Context for RuntimeError {}
impl Context for ConfigError {}
fn read_config(path: impl AsRef<Path>) -> Result<String, Report<ConfigError>> {
std::fs::read_to_string(path.as_ref()).into_report().change_context(ConfigError::IoError)
}
fn main() -> Result<(), Report<RuntimeError>> {
let config_path = "./path/to/config.file";
let config = read_config(config_path)
.change_context_lazy(|| RuntimeError::InvalidConfig(PathBuf::from(config_path)))?;
...
}
Get the attached Backtrace
and SpanTrace
:
use error_stack::{IntoReport, ResultExt, Result};
let config_path = "./path/to/config.file";
let content = std::fs::read_to_string(config_path)
.into_report()
.attach_printable_lazy(|| format!("failed to read config file {config_path:?}"));
let content = match content {
Err(err) => {
for backtrace in err.request_ref::<std::backtrace::Backtrace>() {
println!("backtrace: {backtrace}");
}
for span_trace in err.request_ref::<tracing_error::SpanTrace>() {
println!("span trace: {span_trace}")
}
return Err(err)
}
Ok(ok) => ok
};
...
Implementations
sourceimpl<C> Report<C>
impl<C> Report<C>
sourcepub fn new(context: C) -> Selfwhere
C: Context,
pub fn new(context: C) -> Selfwhere
C: Context,
Creates a new Report<Context>
from a provided scope.
If context
does not provide Backtrace
/SpanTrace
then this attempts to capture
them directly. Please see the Backtrace
and SpanTrace
section of the Report
documentation for more information.
Examples found in repository?
More examples
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
fn start_experiments(
experiment_ids: &[usize],
experiment_descriptions: &[&str],
) -> Result<Vec<u64>, ExperimentError> {
let experiments = experiment_ids
.iter()
.map(|exp_id| {
let description = experiment_descriptions.get(*exp_id).ok_or_else(|| {
Report::new(ExperimentError)
.attach_printable(format!("experiment {exp_id} has no valid description"))
})?;
let experiments = parse_experiment(description)
.attach_printable(format!("experiment {exp_id} could not be parsed"))
.change_context(ExperimentError)?;
let experiments = experiments
.into_iter()
.map(|(a, b)| move || a * b)
.collect::<Vec<_>>();
Ok(experiments)
})
.fold(
Ok(vec![]),
|accum: Result<_, ExperimentError>, value| match (accum, value) {
(Ok(mut accum), Ok(value)) => {
accum.extend(value);
Ok(accum)
}
(Ok(_), Err(err)) => Err(err),
(Err(accum), Ok(_)) => Err(accum),
(Err(mut accum), Err(err)) => {
accum.extend_one(err);
Err(accum)
}
},
)
.attach_printable("unable to set up experiments")?;
Ok(experiments.iter().map(|experiment| experiment()).collect())
}
pub fn backtrace(&self) -> Option<&Backtrace>
request_ref::<Backtrace>()
insteadnightly
and crate feature std
only.pub fn span_trace(&self) -> Option<&SpanTrace>
request_ref::<SpanTrace>()
insteadspantrace
only.sourcepub fn extend_one(&mut self, report: Self)
pub fn extend_one(&mut self, report: Self)
Merge two Report
s together
This function appends the current_frames()
of the other Report
to the
current_frames()
of this report.
Meaning A.extend_one(B) -> A.current_frames() = A.current_frames() + B.current_frames()
use std::{
fmt::{Display, Formatter},
path::Path,
};
use error_stack::{Context, Report, IntoReport, ResultExt};
#[derive(Debug)]
struct IoError;
impl Display for IoError {
...
}
fn read_config(path: impl AsRef<Path>) -> Result<String, Report<IoError>> {
std::fs::read_to_string(path.as_ref())
.into_report()
.change_context(IoError)
}
let mut error1 = read_config("config.txt").unwrap_err();
let error2 = read_config("config2.txt").unwrap_err();
let mut error3 = read_config("config3.txt").unwrap_err();
error1.extend_one(error2);
error3.extend_one(error1);
// ^ This is equivalent to:
// error3.extend_one(error1);
// error3.extend_one(error2);
This function implements the same functionality as
Extend::extend_one
(#7261).
Once stabilised this function will be removed in favor of Extend
.
Examples found in repository?
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
fn parse_experiment(description: &str) -> Result<Vec<(u64, u64)>, ParseExperimentError> {
let values = description
.split(' ')
.map(|value| {
value
.parse::<u64>()
.into_report()
.attach_printable_lazy(|| format!("{value:?} could not be parsed as experiment"))
})
.map(|value| value.map(|ok| (ok, 2 * ok)))
.fold(Ok(vec![]), |accum, value| match (accum, value) {
(Ok(mut accum), Ok(value)) => {
accum.push(value);
Ok(accum)
}
(Ok(_), Err(err)) => Err(err),
(Err(accum), Ok(_)) => Err(accum),
(Err(mut accum), Err(err)) => {
accum.extend_one(err);
Err(accum)
}
})
.change_context(ParseExperimentError)?;
Ok(values)
}
#[derive(Debug)]
struct ExperimentError;
impl fmt::Display for ExperimentError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.write_str("experiment error: could not run experiment")
}
}
impl Context for ExperimentError {}
fn start_experiments(
experiment_ids: &[usize],
experiment_descriptions: &[&str],
) -> Result<Vec<u64>, ExperimentError> {
let experiments = experiment_ids
.iter()
.map(|exp_id| {
let description = experiment_descriptions.get(*exp_id).ok_or_else(|| {
Report::new(ExperimentError)
.attach_printable(format!("experiment {exp_id} has no valid description"))
})?;
let experiments = parse_experiment(description)
.attach_printable(format!("experiment {exp_id} could not be parsed"))
.change_context(ExperimentError)?;
let experiments = experiments
.into_iter()
.map(|(a, b)| move || a * b)
.collect::<Vec<_>>();
Ok(experiments)
})
.fold(
Ok(vec![]),
|accum: Result<_, ExperimentError>, value| match (accum, value) {
(Ok(mut accum), Ok(value)) => {
accum.extend(value);
Ok(accum)
}
(Ok(_), Err(err)) => Err(err),
(Err(accum), Ok(_)) => Err(accum),
(Err(mut accum), Err(err)) => {
accum.extend_one(err);
Err(accum)
}
},
)
.attach_printable("unable to set up experiments")?;
Ok(experiments.iter().map(|experiment| experiment()).collect())
}
sourcepub fn attach<A>(self, attachment: A) -> Selfwhere
A: Send + Sync + 'static,
pub fn attach<A>(self, attachment: A) -> Selfwhere
A: Send + Sync + 'static,
Adds additional information to the Frame
stack.
This behaves like attach_printable()
but will not be shown when printing the Report
.
To benefit from seeing attachments in normal error outputs, use attach_printable()
Note: attach_printable()
will be deprecated when specialization is stabilized and
it becomes possible to merge these two methods.
sourcepub fn attach_printable<A>(self, attachment: A) -> Selfwhere
A: Display + Debug + Send + Sync + 'static,
pub fn attach_printable<A>(self, attachment: A) -> Selfwhere
A: Display + Debug + Send + Sync + 'static,
Adds additional (printable) information to the Frame
stack.
This behaves like attach()
but the display implementation will be called when
printing the Report
.
Note: This will be deprecated in favor of attach()
when specialization is
stabilized it becomes possible to merge these two methods.
Example
use std::{fmt, fs};
use error_stack::{IntoReport, ResultExt};
#[derive(Debug)]
pub struct Suggestion(&'static str);
impl fmt::Display for Suggestion {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt.write_str(self.0)
}
}
let error = fs::read_to_string("config.txt")
.into_report()
.attach(Suggestion("better use a file which exists next time!"));
let report = error.unwrap_err();
let suggestion = report.request_ref::<Suggestion>().next().unwrap();
assert_eq!(suggestion.0, "better use a file which exists next time!");
Examples found in repository?
More examples
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
fn start_experiments(
experiment_ids: &[usize],
experiment_descriptions: &[&str],
) -> Result<Vec<u64>, ExperimentError> {
let experiments = experiment_ids
.iter()
.map(|exp_id| {
let description = experiment_descriptions.get(*exp_id).ok_or_else(|| {
Report::new(ExperimentError)
.attach_printable(format!("experiment {exp_id} has no valid description"))
})?;
let experiments = parse_experiment(description)
.attach_printable(format!("experiment {exp_id} could not be parsed"))
.change_context(ExperimentError)?;
let experiments = experiments
.into_iter()
.map(|(a, b)| move || a * b)
.collect::<Vec<_>>();
Ok(experiments)
})
.fold(
Ok(vec![]),
|accum: Result<_, ExperimentError>, value| match (accum, value) {
(Ok(mut accum), Ok(value)) => {
accum.extend(value);
Ok(accum)
}
(Ok(_), Err(err)) => Err(err),
(Err(accum), Ok(_)) => Err(accum),
(Err(mut accum), Err(err)) => {
accum.extend_one(err);
Err(accum)
}
},
)
.attach_printable("unable to set up experiments")?;
Ok(experiments.iter().map(|experiment| experiment()).collect())
}
sourcepub fn change_context<T>(self, context: T) -> Report<T>where
T: Context,
pub fn change_context<T>(self, context: T) -> Report<T>where
T: Context,
sourcepub fn current_frames(&self) -> &[Frame]
pub fn current_frames(&self) -> &[Frame]
Return the direct current frames of this report,
to get an iterator over the topological sorting of all frames refer to frames()
This is not the same as Report::current_context
, this function gets the underlying
frames that make up this report, while Report::current_context
traverses the stack of
frames to find the current context. A Report
and be made up of multiple Frame
s,
which stack on top of each other. Considering PrintableA<PrintableA<Context>>
,
Report::current_frames
will return the “outer” layer PrintableA
, while
Report::current_context
will return the underlying Context
(the current type
parameter of this Report
)
Using Extend
and extend_one()
, a Report
can additionally be made up of multiple
stacks of frames and builds a “group” of them, but a Report
can only ever have a single
Context
, therefore this function returns a slice instead, while
Report::current_context
only returns a single reference.
sourcepub fn frames(&self) -> Frames<'_>ⓘNotable traits for Frames<'r>impl<'r> Iterator for Frames<'r> type Item = &'r Frame;
pub fn frames(&self) -> Frames<'_>ⓘNotable traits for Frames<'r>impl<'r> Iterator for Frames<'r> type Item = &'r Frame;
Returns an iterator over the Frame
stack of the report.
sourcepub fn frames_mut(&mut self) -> FramesMut<'_>ⓘNotable traits for FramesMut<'r>impl<'r> Iterator for FramesMut<'r> type Item = &'r mut Frame;
pub fn frames_mut(&mut self) -> FramesMut<'_>ⓘNotable traits for FramesMut<'r>impl<'r> Iterator for FramesMut<'r> type Item = &'r mut Frame;
Returns an iterator over the Frame
stack of the report with mutable elements.
sourcepub fn request_ref<T: ?Sized + Send + Sync + 'static>(
&self
) -> RequestRef<'_, T>ⓘNotable traits for RequestRef<'r, T>impl<'r, T> Iterator for RequestRef<'r, T>where
T: ?Sized + 'static, type Item = &'r T;
Available on nightly
only.
pub fn request_ref<T: ?Sized + Send + Sync + 'static>(
&self
) -> RequestRef<'_, T>ⓘNotable traits for RequestRef<'r, T>impl<'r, T> Iterator for RequestRef<'r, T>where
T: ?Sized + 'static, type Item = &'r T;
T: ?Sized + 'static, type Item = &'r T;
nightly
only.sourcepub fn request_value<T: Send + Sync + 'static>(&self) -> RequestValue<'_, T>ⓘNotable traits for RequestValue<'r, T>impl<'r, T> Iterator for RequestValue<'r, T>where
T: 'static, type Item = T;
Available on nightly
only.
pub fn request_value<T: Send + Sync + 'static>(&self) -> RequestValue<'_, T>ⓘNotable traits for RequestValue<'r, T>impl<'r, T> Iterator for RequestValue<'r, T>where
T: 'static, type Item = T;
T: 'static, type Item = T;
nightly
only.sourcepub fn downcast_ref<T: Send + Sync + 'static>(&self) -> Option<&T>
pub fn downcast_ref<T: Send + Sync + 'static>(&self) -> Option<&T>
Searches the frame stack for a context provider T
and returns the most recent context
found.
T
can either be an attachment or a Context
.
Example
use std::io;
fn read_file(path: impl AsRef<Path>) -> Result<String, Report<io::Error>> {
...
}
let report = read_file("test.txt").unwrap_err();
let io_error = report.downcast_ref::<io::Error>().unwrap();
assert_eq!(io_error.kind(), io::ErrorKind::NotFound);
sourcepub fn downcast_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
pub fn downcast_mut<T: Send + Sync + 'static>(&mut self) -> Option<&mut T>
Searches the frame stack for an instance of type T
, returning the most recent one found.
T
can either be an attachment or a Context
.
sourcepub fn current_context(&self) -> &Cwhere
C: Display + Send + Sync + 'static,
pub fn current_context(&self) -> &Cwhere
C: Display + Send + Sync + 'static,
Returns the current context of the Report
.
If the user want to get the latest context, current_context
can be called. If the user
wants to handle the error, the context can then be used to directly access the context’s
type. This is only possible for the latest context as the Report does not have multiple
generics as this would either require variadic generics or a workaround like tuple-list.
This is one disadvantage of the library in comparison to plain Errors, as in these cases, all context types are known.
Example
use std::io;
fn read_file(path: impl AsRef<Path>) -> Result<String, Report<io::Error>> {
...
}
let report = read_file("test.txt").unwrap_err();
let io_error = report.current_context();
assert_eq!(io_error.kind(), io::ErrorKind::NotFound);
sourceimpl Report<()>
impl Report<()>
sourcepub fn install_debug_hook<T: Send + Sync + 'static>(
hook: impl Fn(&T, &mut HookContext<T>) + Send + Sync + 'static
)
Available on crate feature std
only.
pub fn install_debug_hook<T: Send + Sync + 'static>(
hook: impl Fn(&T, &mut HookContext<T>) + Send + Sync + 'static
)
std
only.Can be used to globally set a Debug
format hook, for a specific type T
.
This hook will be called on every Debug
call, if an attachment with the same type has
been found.
Examples
use std::io::{Error, ErrorKind};
use error_stack::{
report, Report,
};
struct Suggestion(&'static str);
Report::install_debug_hook::<Suggestion>(|value, context| {
context.push_body(format!("suggestion: {}", value.0));
});
let report =
report!(Error::from(ErrorKind::InvalidInput)).attach(Suggestion("oh no, try again"));
println!("{report:?}");
Which will result in something like:
invalid input parameter ├╴src/hook.rs:19:5 ├╴backtrace (1) ╰╴suggestion: oh no, try again ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ backtrace no. 1 [redacted]
This example showcases the ability of hooks to be invoked for values provided via the
Provider API using Error::provide
.
#![feature(error_generic_member_access, provide_any)]
use std::any::Demand;
use std::error::Error;
use std::fmt::{Display, Formatter};
use error_stack::{Report, report};
struct Suggestion(&'static str);
#[derive(Debug)]
struct ErrorCode(u64);
#[derive(Debug)]
struct UserError {
code: ErrorCode
}
impl Display for UserError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str("invalid user input")
}
}
impl Error for UserError {
fn provide<'a>(&'a self, req: &mut Demand<'a>) {
req.provide_value(Suggestion("try better next time!"));
req.provide_ref(&self.code);
}
}
Report::install_debug_hook::<Suggestion>(|Suggestion(value), context| {
context.push_body(format!("suggestion: {value}"));
});
Report::install_debug_hook::<ErrorCode>(|ErrorCode(value), context| {
context.push_body(format!("error code: {value}"));
});
let report = report!(UserError {code: ErrorCode(420)});
println!("{report:?}");
Which will result in something like:
invalid user input ├╴src/hook.rs:49:14 ├╴suggestion: try better next time! ├╴error code: 420 ╰╴backtrace (1) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ backtrace no. 1 [redacted]
sourcepub fn set_debug_hook<H>(hook: H) -> Result<(), HookAlreadySet>where
H: Fn(&Self, &mut Formatter<'_>) -> Result + Send + Sync + 'static,
👎Deprecated since 0.2.0: use Report::install_debug_hook() insteadAvailable on crate feature std
only.
pub fn set_debug_hook<H>(hook: H) -> Result<(), HookAlreadySet>where
H: Fn(&Self, &mut Formatter<'_>) -> Result + Send + Sync + 'static,
std
only.Globally sets a hook which is called when formatting Report
with the Debug
trait.
By intercepting the default Debug
implementation, this hook adds the possibility for
downstream crates to provide their own formatting like colored output or a machine-readable
output (i.e. JSON).
If not set, Debug
will print
Note
Since 0.2
this will overwrite the previous hook (if set) instead of returning
HookAlreadySet
.
Errors
No longer returns an error since version 0.2
, the return value has been preserved for
compatibility.
Example
use std::io::{Error, ErrorKind};
use error_stack::{report, Report};
#[allow(deprecated)]
Report::set_debug_hook(|_, fmt| write!(fmt, "custom debug implementation"))?;
let report = report!(Error::from(ErrorKind::InvalidInput));
assert_eq!(format!("{report:?}"), "custom debug implementation");
sourcepub fn set_display_hook<H>(hook: H) -> Result<(), HookAlreadySet>where
H: Fn(&Self, &mut Formatter<'_>) -> Result + Send + Sync + 'static,
👎Deprecated since 0.2.0Available on crate feature std
only.
pub fn set_display_hook<H>(hook: H) -> Result<(), HookAlreadySet>where
H: Fn(&Self, &mut Formatter<'_>) -> Result + Send + Sync + 'static,
std
only.Globally sets a hook that is called when formatting Report
with the Display
trait.
By intercepting the default Display
implementation, this hook adds the possibility
for downstream crates to provide their own formatting like colored output or a
machine-readable output (i.e. JSON).
If not set, Display
will print the latest error and, if alternate formatting is enabled
("{:#}"
) and it exists, its direct cause.
Note
Since 0.2
this will overwrite the previous hook (if set) instead of returning
HookAlreadySet
.
Errors
No longer returns an error since version 0.2
, the return value has been preserved for
compatibility.
Example
use std::io::{Error, ErrorKind};
use error_stack::{report, Report};
#[allow(deprecated)]
Report::set_display_hook(|_, fmt| write!(fmt, "custom display implementation"))?;
let report = report!(Error::from(ErrorKind::InvalidInput));
assert_eq!(report.to_string(), "custom display implementation");
Trait Implementations
sourceimpl<Context> Extend<Report<Context>> for Report<Context>
impl<Context> Extend<Report<Context>> for Report<Context>
sourcefn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T)
fn extend<T: IntoIterator<Item = Self>>(&mut self, iter: T)
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl<Context> FromIterator<Report<Context>> for Option<Report<Context>>
impl<Context> FromIterator<Report<Context>> for Option<Report<Context>>
sourcefn from_iter<T: IntoIterator<Item = Report<Context>>>(iter: T) -> Self
fn from_iter<T: IntoIterator<Item = Report<Context>>>(iter: T) -> Self
Auto Trait Implementations
impl<C> !RefUnwindSafe for Report<C>
impl<C> Send for Report<C>
impl<C> Sync for Report<C>
impl<C> Unpin for Report<C>
impl<C> !UnwindSafe for Report<C>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<D> OwoColorize for D
impl<D> OwoColorize for D
sourcefn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
sourcefn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
sourcefn black(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black(&'a self) -> FgColorDisplay<'a, Black, Self>
sourcefn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black(&'a self) -> BgColorDisplay<'a, Black, Self>
sourcefn red(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red(&'a self) -> FgColorDisplay<'a, Red, Self>
sourcefn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red(&'a self) -> BgColorDisplay<'a, Red, Self>
sourcefn green(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green(&'a self) -> FgColorDisplay<'a, Green, Self>
sourcefn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green(&'a self) -> BgColorDisplay<'a, Green, Self>
sourcefn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow(&'a self) -> FgColorDisplay<'a, Yellow, Self>
sourcefn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow(&'a self) -> BgColorDisplay<'a, Yellow, Self>
sourcefn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue(&'a self) -> FgColorDisplay<'a, Blue, Self>
sourcefn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue(&'a self) -> BgColorDisplay<'a, Blue, Self>
sourcefn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta(&'a self) -> FgColorDisplay<'a, Magenta, Self>
sourcefn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta(&'a self) -> BgColorDisplay<'a, Magenta, Self>
sourcefn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple(&'a self) -> FgColorDisplay<'a, Magenta, Self>
sourcefn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple(&'a self) -> BgColorDisplay<'a, Magenta, Self>
sourcefn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan(&'a self) -> FgColorDisplay<'a, Cyan, Self>
sourcefn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan(&'a self) -> BgColorDisplay<'a, Cyan, Self>
sourcefn white(&'a self) -> FgColorDisplay<'a, White, Self>
fn white(&'a self) -> FgColorDisplay<'a, White, Self>
sourcefn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white(&'a self) -> BgColorDisplay<'a, White, Self>
sourcefn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color(&'a self) -> FgColorDisplay<'a, Default, Self>
sourcefn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color(&'a self) -> BgColorDisplay<'a, Default, Self>
sourcefn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
sourcefn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
sourcefn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
sourcefn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
sourcefn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
sourcefn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
sourcefn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
sourcefn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
sourcefn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
sourcefn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
sourcefn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
sourcefn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
sourcefn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
sourcefn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
sourcefn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
sourcefn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
sourcefn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
sourcefn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
sourcefn bold(&'a self) -> BoldDisplay<'a, Self>
fn bold(&'a self) -> BoldDisplay<'a, Self>
sourcefn dimmed(&'a self) -> DimDisplay<'a, Self>
fn dimmed(&'a self) -> DimDisplay<'a, Self>
sourcefn italic(&'a self) -> ItalicDisplay<'a, Self>
fn italic(&'a self) -> ItalicDisplay<'a, Self>
sourcefn underline(&'a self) -> UnderlineDisplay<'a, Self>
fn underline(&'a self) -> UnderlineDisplay<'a, Self>
sourcefn blink(&'a self) -> BlinkDisplay<'a, Self>
fn blink(&'a self) -> BlinkDisplay<'a, Self>
sourcefn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast(&'a self) -> BlinkFastDisplay<'a, Self>
sourcefn reversed(&'a self) -> ReversedDisplay<'a, Self>
fn reversed(&'a self) -> ReversedDisplay<'a, Self>
sourcefn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough(&'a self) -> StrikeThroughDisplay<'a, Self>
sourcefn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg
or
a color-specific method, such as OwoColorize::green
, Read moresourcefn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg
or
a color-specific method, such as OwoColorize::on_yellow
, Read moresourcefn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn fg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> FgColorDisplay<'_, CustomColor<R, G, B>, Self>
sourcefn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
fn bg_rgb<const R: u8, const G: u8, const B: u8>(
&self
) -> BgColorDisplay<'_, CustomColor<R, G, B>, Self>
sourcefn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
fn truecolor(&self, r: u8, g: u8, b: u8) -> FgDynColorDisplay<'_, Rgb, Self>
sourcefn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
fn on_truecolor(&self, r: u8, g: u8, b: u8) -> BgDynColorDisplay<'_, Rgb, Self>
sourcefn if_supports_color<'a, Out, ApplyFn>(
&'a self,
stream: Stream,
apply: ApplyFn
) -> SupportsColorsDisplay<'a, Self, Out, ApplyFn>where
ApplyFn: Fn(&'a Self) -> Out,
fn if_supports_color<'a, Out, ApplyFn>(
&'a self,
stream: Stream,
apply: ApplyFn
) -> SupportsColorsDisplay<'a, Self, Out, ApplyFn>where
ApplyFn: Fn(&'a Self) -> Out,
supports-colors
only.