resext

Crates.ioresext
lib.rsresext
version0.7.0
created_at2025-12-26 22:39:55.741758+00
updated_at2026-01-18 01:16:09.403113+00
descriptionA simple, lightweight error handling crate for Rust with no-std support coming soon
homepage
repositoryhttps://github.com/Tahaa-Dev/ResExt
max_upload_size
id2006368
size28,592
Taha Mahmoud (Tahaa-Dev)

documentation

README

ResExt

crates.io docs.rs CI License: MIT

Simple, lightweight, low-alloc error handling crate for Rust.

ResExt provides a declarative macro (ResExt! {}) for easy, ergonomic and performant error-handling.


Quick Start

Add ResExt to your dependencies:

cargo add resext
  • or add this to your Cargo.toml:
[dependencies]
resext = "0.7.0"

Basic Usage

use resext::ResExt;

ResExt! {
    enum MyError {
        Io(std::io::Error),
        Env(std::env::VarError),
        Network(reqwest::Error),
        Other,
    }
}

This code generates:

  1. MyError enum with Error, Debug and Display implementations
  2. From<T> for MyError for types of the enum's tuple variants
  3. ResErr struct for context wrapper around MyError
  4. ResExt trait with context methods
  5. Res<T> type alias for Result<T, MyError>

Example

use resext::ResExt;
use std::io;
use crate::Data;

ResExt! {
    enum ErrorTypes {
        Io(io::Error),
        Network(reqwest::Error),
        Other,
    }
}

async fn parse_page(url: String) -> Res<Data> {
    let content = reqwest::get(url).await
        .with_context(|| format!("Failed to fetch URL: {}", url))?;

    let data: Data = crate::parse_page_content(content)
        .context("Failed to parse page data")?;

    Ok(data)
}

ResExt uses a unique approach for error-handling that provides anyhow methods and convenient error-propagation as well as thiserror's performance and concrete types with a macro that generates both methods and the error enum locally in your project.


Notes

  • ResExt is still in heavy development, wait for v1.0.0 to rely on it for production code.
  • For changes, see CHANGELOG.md.
  • For contribution details, see CONTRIBUTING.md.
  • This project is licensed under the MIT license.
Commit count: 38

cargo fmt