Closed connorkuehl closed 3 years ago
This still smells of NIH despite httparse taking care of the parsing. The Response struct I wrote is (as far as I can tell from the httparse documentation) necessary for filling a usability gap in client code (i.e., fn download).
edit: to elaborate on the usability gap I alluded to:
httparse::Response
still requires no small amount of effort from client code since it's non-allocating, it's not tidied up into a data structure that makes lookups convenient (hashmap vs array). Checking for the retry header would still be an array traversal, which would just clutter up the call site.httparse::Response
would require a C-like function where the caller allocates a buffer and passes it in so that the lifetime of the httparse::Response
can align with it. Even if we did this, point 1 still applies.httparse::Response
struct with a struct of our own, just much uglier and nontrivial lifetime decorations on the struct and its impl.Because of the above points, I decided to fill that gap with a Response abstraction that copies whatever data it needs from the httparse::Response
and organizes it in a way that's convenient to use in src/main.rs
.
@connorkuehl I'm not worried about the NIH smell. We need to keep dependencies small.
We are underutilizing reqwests in comparison to the downstream packaging complexity it adds for when this crate must vendor its sources.
This also shrinks the dependency graph.
Signed-off-by: Connor Kuehl ckuehl@redhat.com