-
Notifications
You must be signed in to change notification settings - Fork 65
Make PreparedSend
cloneable
#687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
I don't know if this is a good defense against the flow you mentioned. For example, when this will be exposed via bindings, there is no way to enforce the same rust-specific ownership protections in let's say javascript. So it's safe to assume at least some callers will be able to clone with no problem. IMO the more robust way is to make this cloneable (since we cannot reliably forbid it) and rely on a different mechanism to avoid |
What is the use case for which Because JavaScript users can do something dangerous, we should allow Rust users to do something dangerous isn't a compelling reason to allow this, imo. |
Most apps are multi-threaded (UI thread, background threads), so they pass data either by reference with So it's therefore natural that callers will try to either
If that's not possible, they'll have to
In rust, callers can be blocked from the first 2 options and essentially forced to use the 3rd. But CDK is planning to add bindings. Do you know for sure which languages will be covered by the bindings? Will those users be doing something "dangerous" if they try to clone an object or use it as reference, which they already do in the rest of their app? Is the CDK team prepared to 1) document why this shouldn't be attempted, 2) keep an eye out for all future binding languages and make sure the exposed Seems to me a bit unfair to callers, and not a very robust way forward for CDK. Since we can't reliably forbid it, we should allow cloning and instead rely on CDK-internal mechanisms to handle the |
I haven't encountered this issue when building CDK-Flutter using a widget or the Wallet Rust struct and Dart class. If someone needed to use a prepared send across multiple threads, although I can't think of a reason why anyone would do that, using a Mutex seems reasonable to me to avoid trying to process a send twice. |
Description
This PR makes
PreparedSend
cloneable. This is useful for callers when handling the send cancellation, which may happen in a context that only has a&PreparedSend
.Checklist
just final-check
before committing