Skip to main content

ValknutResultExt

Trait ValknutResultExt 

Source
pub trait ValknutResultExt<T> {
    // Required methods
    fn map_io_err(self, message: impl Into<String>) -> Result<T>;
    fn map_json_err(self, context: impl Into<String>) -> Result<T>;
    fn map_generic_err(self, operation: impl Into<String>) -> Result<T>;
}
Expand description

Extension trait for common error mapping patterns

Required Methods§

Source

fn map_io_err(self, message: impl Into<String>) -> Result<T>

Map I/O errors with a custom message

Source

fn map_json_err(self, context: impl Into<String>) -> Result<T>

Map JSON parsing errors with context

Source

fn map_generic_err(self, operation: impl Into<String>) -> Result<T>

Map generic errors with operation context

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T, E> ValknutResultExt<T> for Result<T, E>
where E: Display,

ValknutResultExt implementation for results with displayable errors.

Source§

fn map_io_err(self, message: impl Into<String>) -> Result<T>

Maps errors to an internal error with an I/O-style message prefix.

Source§

fn map_json_err(self, context: impl Into<String>) -> Result<T>

Maps errors to an internal error with JSON context.

Source§

fn map_generic_err(self, operation: impl Into<String>) -> Result<T>

Maps errors to an internal error with operation context.

Implementors§