Trait Z

Source
pub trait Z {
    type Error;

    // Required methods
    fn long_form(&self) -> String;
    fn with_info<X: Debug>(self, name: &str, value: X) -> Self::Error;
    fn with_lazy_info<F: FnOnce() -> String>(
        self,
        name: &str,
        value: F,
    ) -> Self::Error;
}
Expand description

The core type of zerror. Implement this trait, or wrap and proxy ErrorCore, to create rich errors in the long_form. This integrates with the error handling “monad” over Result<T, Z>.

Required Associated Types§

Source

type Error

The type of error returned from the with_* methods.

Required Methods§

Source

fn long_form(&self) -> String

Convert an error to a string free from “=”*80.

Source

fn with_info<X: Debug>(self, name: &str, value: X) -> Self::Error

Add debug formatting of a local variable.

Source

fn with_lazy_info<F: FnOnce() -> String>( self, name: &str, value: F, ) -> Self::Error

Add debug formatting using a closure.

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: Z<Error = E>> Z for Result<T, E>

Source§

type Error = Result<T, E>

Source§

fn long_form(&self) -> String

Source§

fn with_info<X: Debug>(self, name: &str, value: X) -> Self::Error

Source§

fn with_lazy_info<F: FnOnce() -> String>( self, name: &str, value: F, ) -> Self::Error

Implementors§