cetra3 / mpart-async

Asynchronous Multipart Requests for Rust
Apache License 2.0
32 stars 13 forks source link

Removal of anyhow usage #9

Closed koivunej closed 4 years ago

koivunej commented 4 years ago

Creating this issue to follow up on the "removal of anyhow usage" from the API. Rationale is that anyhow is for end applications, but for libraries it doesn't work so well as the library users cannot pattern match the errors. Instead of hastly PR'ing my suggestion I see there are three alternative approaches:

  1. Make MultipartError generic over the inner stream Error
  2. Box stream error through Into<Box<std::error::Error + Sync + Send + 'static>>
  3. Wrap MultipartParser::Item, MultipartField::Item in another Result<_, E> where E == inner stream error (a la sled errors)

The first one can certainly done, or I have already done it. The second is a variation on the first, but perhaps easy enough for the end users. I started thinking about the third one now that I am looking at the conflicts. The main difference between the approaches is that the first one will absorb the inner error, while the second one will cleanly separate multipart decoding errors from more std::io::Error like cases. Though, the third option would make the most sense if the multipart parsing errors were not critical or could be recovered, which they are not.

Either way this is a breaking change so it should come with a minor version bump. I am perhaps leaning towards to the boxed std::error::Error, the generic type is not too nice to carry around.