generic-err

Crates.iogeneric-err
lib.rsgeneric-err
version0.1.0
created_at2025-04-07 08:36:01.131704+00
updated_at2025-04-07 08:36:01.131704+00
descriptionA small utility library to make errors always serializable and clonable
homepage
repositoryhttps://github.com/ActuallyHappening/YMap/tree/master/generic-error
max_upload_size
id1623817
size11,968
Caleb Yates (ActuallyHappening)

documentation

https://docs.rs/generic-err

README

Generic Error

A simple utility to convert any error type that isn't clonable into one that is, while preserving source information providing Serialize and Deserialize functionality. Magic?

How it works

The GenericError<E> wrapper type just stores the Display and Debug implementations of the wrapped type, which is now always clonable and will serialize just fine. The GenericError<E> type kinda looks like this:

#[derive(Serialize, Deserialize, Clone)]
pub struct GenericError<T>
{
  display: String,
  debug: String,
  source: Option<GenericError>,
}

.. although many details have been omitted for brevity

See docs or the examples dir for usage

Commit count: 142

cargo fmt