Expose Sender::extract_v2 for bindings#382
Merged
DanGould merged 3 commits intopayjoin:masterfrom Nov 11, 2024
Merged
Conversation
The send::Context typestate enum is not simple to bind to in UniFFI and would require abstracting distinct extract_v1 extract_v2 functions in order to cross the FFI boundary. Exposing this method is a simple fix to make such abstraction unnecessary.
DanGould
commented
Nov 6, 2024
payjoin/src/send/mod.rs
Outdated
Comment on lines
291
to
294
| Ok(rs) => self.extract_v2(ohttp_relay, rs), | ||
| Ok(_rs) => { | ||
| let (req, context_v2) = self.extract_v2(ohttp_relay)?; | ||
| Ok((req, Context::V2(context_v2))) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
I wonder if it even makes sense to have this match extract_highest_version since it still requires a match on the resulting Context to handle both processing v1 and v2
It may be simpler to just have the downstream implementor switch on whether or not extract_v2 errors, then try extract_v1 (if it's a version error), and otherwise return an error.
Collaborator
There was a problem hiding this comment.
I agree that the try/catch pattern on extract_v2 seems cleaner.
7a136f0 to
0c49db3
Compare
The send::Context typestate enum is not simple to bind to in UniFFI, and the extract_highest_version function is not very useful because it still requires the caller to match on the resulting Context.
0c49db3 to
f6247ff
Compare
spacebear21
reviewed
Nov 7, 2024
Collaborator
spacebear21
left a comment
There was a problem hiding this comment.
I deleted the Context enum and extract_highest_version in favor of the "try extract_v2" approach. Also refactored http posts to save vertical space.
Contributor
Author
|
tACK new changes up to f6247ff. I can't "Approve" my own PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The send::Context typestate enum is not simple to bind to in UniFFI and would require abstracting distinct extract_v1 extract_v2 functions in order to cross the FFI boundary. Exposing this method is a simple fix to make such abstraction unnecessary.