Move shared response processing code to ohttp.rs
The process_res methods across send and receive have a lot of shared code that can be extracted into reusable functions. process_get_res and process_post_res essentially do the same thing, and could conceivably be combined into one function. They were kept separate because "202 Accepted" is not a valid response for POST requests.
Leaving in draft for now because some follow-up items need to be addressed:
- process_response methods return inconsistent error types when POSTing vs. GETting, specifically: EncapsulationError vs. ResponseError for send and SessionError vs. Error for receive.
- There are four duplicated variants between InternalEncapsulationError and InternalSessionError.
- Also, EncapsulationError is a misnomer since it afaict it's exclusively raised when decapsulating responses.
- The Hpke variant has nothing to do with en/decapsulation.
Pull Request Test Coverage Report for Build 15500115610
Details
- 51 of 75 (68.0%) changed or added relevant lines in 5 files are covered.
- No unchanged relevant lines lost coverage.
- Overall coverage decreased (-0.01%) to 85.043%
| Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
|---|---|---|---|
| payjoin/src/receive/v2/error.rs | 0 | 2 | 0.0% |
| payjoin/src/send/v2/error.rs | 0 | 3 | 0.0% |
| payjoin/src/ohttp.rs | 28 | 47 | 59.57% |
| <!-- | Total: | 51 | 75 |
| Totals | |
|---|---|
| Change from base Build 15449709719: | -0.01% |
| Covered Lines: | 6772 |
| Relevant Lines: | 7963 |
💛 - Coveralls
are there other from conversions that can be deleted?
The error audit I mentioned in my other comment can be addressed later in a follow-up, I'll make a new issue.
are there other from conversions that can be deleted?
I had a second commit locally that I hadn't pushed which simplifies the From mappings. The PR is still a net addition but I think the simplification is significant.
The latest push fixes process_get_res and replaces the From implementations with map_err.
ec4b67e7f39ee8e707c7a272b7459fb836ae0a50 only applies your suggestions re: response.status().