pub trait OptionContext<T>: Sealed {
// Required methods
fn error(self, context: impl Display) -> Option<T>;
fn warn(self, context: impl Display) -> Option<T>;
fn info(self, context: impl Display) -> Option<T>;
fn debug(self, context: impl Display) -> Option<T>;
fn trace(self, context: impl Display) -> Option<T>;
fn with_error<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>;
fn with_warn<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>;
fn with_info<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>;
fn with_debug<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>;
fn with_trace<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>;
}Available on crate features
tracing or log or defmt or context_stub only.Expand description
For logging when a None is encountered.
Required Methods§
Sourcefn error(self, context: impl Display) -> Option<T>
fn error(self, context: impl Display) -> Option<T>
Log the context as an “error” if the Option is None.
Sourcefn warn(self, context: impl Display) -> Option<T>
fn warn(self, context: impl Display) -> Option<T>
Log the context as an “warn” if the Option is None.
Sourcefn info(self, context: impl Display) -> Option<T>
fn info(self, context: impl Display) -> Option<T>
Log the context as an “info” if the Option is None.
Sourcefn debug(self, context: impl Display) -> Option<T>
fn debug(self, context: impl Display) -> Option<T>
Log the context as an “debug” if the Option is None.
Sourcefn trace(self, context: impl Display) -> Option<T>
fn trace(self, context: impl Display) -> Option<T>
Log the context as an “trace” if the Option is None.
Sourcefn with_error<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_error<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Lazily call [f] if the Option is None and log as an “error”.
Sourcefn with_warn<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_warn<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Lazily call [f] if the Option is None and log as an “warn”.
Sourcefn with_info<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_info<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Lazily call [f] if the Option is None and log as an “info”.
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<T> OptionContext<T> for Option<T>
Available on crate features tracing or log or context_stub only.
impl<T> OptionContext<T> for Option<T>
Available on crate features
tracing or log or context_stub only.Source§fn error(self, context: impl Display) -> Option<T>
fn error(self, context: impl Display) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn warn(self, context: impl Display) -> Option<T>
fn warn(self, context: impl Display) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn info(self, context: impl Display) -> Option<T>
fn info(self, context: impl Display) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn debug(self, context: impl Display) -> Option<T>
fn debug(self, context: impl Display) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn trace(self, context: impl Display) -> Option<T>
fn trace(self, context: impl Display) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn with_error<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_error<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn with_warn<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_warn<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.Source§fn with_info<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
fn with_info<F: FnOnce() -> D, D: Display>(self, f: F) -> Option<T>
Available on crate features
tracing or log or defmt or context_stub only.