Skip to content

Make serialize_url and extract_v1 infallible#579

Merged
spacebear21 merged 2 commits intopayjoin:masterfrom
spacebear21:infallible-serialize-url
Mar 15, 2025
Merged

Make serialize_url and extract_v1 infallible#579
spacebear21 merged 2 commits intopayjoin:masterfrom
spacebear21:infallible-serialize-url

Conversation

@spacebear21
Copy link
Collaborator

I noticed that serialize_url returns a Result<Url, url::ParseError> but never actually returns an Err, so it can simply return a Url instead. The first commit addresses this.

By extension, Sender::extract_v1 no longer needs to return a Result either. The second commit addresses this. However, that one is a breaking change so I can remove this commit if that's undesired.

serialize_url returns a Result<> but an Error is never thrown. Simply
return a Url instead.
@spacebear21 spacebear21 requested a review from DanGould March 13, 2025 22:17
Now that serialize_url is infallible, extract_v1 no longer needs to
return a Result either.
@coveralls
Copy link
Collaborator

coveralls commented Mar 13, 2025

Pull Request Test Coverage Report for Build 13845718794

Details

  • 14 of 15 (93.33%) changed or added relevant lines in 6 files are covered.
  • 2 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.04%) to 80.595%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin-cli/src/app/v2.rs 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
payjoin/src/send/mod.rs 2 94.31%
Totals Coverage Status
Change from base Build 13844597959: -0.04%
Covered Lines: 4826
Relevant Lines: 5988

💛 - Coveralls

@spacebear21 spacebear21 force-pushed the infallible-serialize-url branch from 8fb0f60 to cc905ec Compare March 13, 2025 22:20
Copy link
Collaborator

@benalleng benalleng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting rid of the Result here seems to be a nice simplification, I couldn't find anything hidden in serialize_url or extract_v1 that would negate these being made infallible.

I can't speak to whether or not making a breaking change is worth it or not.

Copy link
Contributor

@DanGould DanGould left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 2b9a6a1

I poked around to make sure the InternalCreateRequestError::Url variant thrown was still being used, and it is, so this all looks good to me.

I'm ok breaking the API, our team faces the biggest burden to make it work in bindings so lets break the API while we still have few dependencies we have capacity to communicate API breaks with.

@DanGould DanGould added the api label Mar 15, 2025
@spacebear21 spacebear21 merged commit 480cadd into payjoin:master Mar 15, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants