BoxedResult

Type Alias BoxedResult 

Source
pub type BoxedResult<T, E> = Result<T, Box<ComposableError<E>>>;
Expand description

Convenient result type alias for functions returning boxed composable errors.

This is the recommended return type for public API functions as it has minimal stack footprint (8 bytes) while providing full error context.

§Examples

use error_rail::prelude::*;

fn read_file(path: &str) -> BoxedResult<String, std::io::Error> {
   // In a real app, this would be std::fs::read_to_string(path)
   Err(std::io::Error::new(std::io::ErrorKind::Other, "mock error"))
        .ctx("reading file")
}

assert!(read_file("test.txt").is_err());

Aliased Type§

pub enum BoxedResult<T, E> {
    Ok(T),
    Err(Box<ComposableError<E>>),
}

Variants§

§1.0.0

Ok(T)

Contains the success value

§1.0.0

Err(Box<ComposableError<E>>)

Contains the error value