#arc #rc #error

arcerror

Provides thin wrappers around Arc<T> and Rc<T> where T: Error. Impls Error for both of these types. No unsafe, no dependencies.

2 releases

Uses new Rust 2021

0.1.4 Oct 15, 2022
0.1.3 Oct 15, 2022
0.1.2 Oct 15, 2022
0.1.1 Oct 15, 2022
0.1.0 Oct 15, 2022

#730 in Rust patterns

Download history 129/week @ 2022-10-11 9/week @ 2022-10-18 16/week @ 2022-10-25 30/week @ 2022-11-01 43/week @ 2022-11-08 7/week @ 2022-11-15 1/week @ 2022-11-22

82 downloads per month

MIT license

6KB
78 lines

arcerror

Provides thin wrappers around Arc<T> and Rc<T> where T: Error. Impls Error for both of these types. No unsafe, no dependencies.

The purpose of this is to impl Clone for arbitrary Error types that don't already have such an implementation. The use case that drove it was for an HTTP server that was making an HTTP request for large files through a third-party wrapper around an API, and streaming the response to both a File on the local filesystem and to our own HTTP response concurrently, through a broadcast channel.

A network stream can fail at any time, so every "chunk" is returned in a Result; the third-party wrapper crate didn't impl Clone on its error type (and many of the errors it was wrapping also don't impl Clone). This is a solution to making that Result impl Clone.

No runtime deps