Skip to main content

DecrustResultExt

Trait DecrustResultExt 

Source
pub trait DecrustResultExt<T, EOrig> {
    // Required methods
    fn decrust_context_msg(self, message: &str) -> Result<T, DecrustError>;
    fn decrust_context_msg_owned(
        self,
        message: String,
    ) -> Result<T, DecrustError>;
    fn decrust_context_rich(
        self,
        context: ErrorContext,
    ) -> Result<T, DecrustError>;
}
Expand description

Extension trait for Result types to add context to errors

This trait provides methods to add context to errors in a Result, making it easier to provide additional information about the error.

This trait is object-safe and can be used with dynamic dispatch.

Required Methods§

Source

fn decrust_context_msg(self, message: &str) -> Result<T, DecrustError>

Adds a simple message context to an error in a Result

§Parameters
  • message - The message to add as context
§Returns

A new Result with the error wrapped in a WithRichContext variant if it was an error

Source

fn decrust_context_msg_owned(self, message: String) -> Result<T, DecrustError>

Adds a simple message context to an error in a Result (owned string version)

§Parameters
  • message - The message to add as context
§Returns

A new Result with the error wrapped in a WithRichContext variant if it was an error

Source

fn decrust_context_rich(self, context: ErrorContext) -> Result<T, DecrustError>

Adds rich context to an error in a Result

§Parameters
  • context - The error context to add
§Returns

A new Result with the error wrapped in a WithRichContext variant if it was an error

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, E> DecrustResultExt<T, E> for Result<T, E>
where E: Into<DecrustError>,

Implementors§